Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #if 0
  2. assert(
  3. static_cast<std::size_t>((std::numeric_limits<std::streamsize>::max)()) >= count
  4. );
  5. //if(is.fail())
  6. // boost::throw_exception(archive_exception(archive_exception::stream_error));
  7. // note: an optimizer should eliminate the following for char files
  8. std::size_t s = count / sizeof(BOOST_DEDUCED_TYPENAME IStream::char_type);
  9. is.read(
  10. static_cast<BOOST_DEDUCED_TYPENAME IStream::char_type *>(address),
  11. s
  12. );
  13. // note: an optimizer should eliminate the following for char files
  14. s = count % sizeof(BOOST_DEDUCED_TYPENAME IStream::char_type);
  15. if(0 < s){
  16. if(is.fail())
  17. boost::throw_exception(archive_exception(archive_exception::stream_error));
  18. BOOST_DEDUCED_TYPENAME IStream::char_type t;
  19. is.read(& t, 1);
  20. std::memcpy(address, &t, s);
  21. }
  22. #endif
  23. // note: an optimizer should eliminate the following for char files
  24. std::streamsize s = count / sizeof(Elem);
  25. std::streamsize scount = m_sb.sgetn(
  26. static_cast<Elem *>(address),
  27. s
  28. );
  29. if(count != static_cast<std::size_t>(s))
  30. boost::throw_exception(
  31. archive_exception(archive_exception::stream_error)
  32. );
  33. // note: an optimizer should eliminate the following for char files
  34. s = count % sizeof(Elem);
  35. if(0 < s){
  36. // if(is.fail())
  37. // boost::throw_exception(archive_exception(archive_exception::stream_error));
  38. Elem t;
  39. scount = m_sb.sgetn(& t, 1);
  40. if(count != 1)
  41. boost::throw_exception(
  42. archive_exception(archive_exception::stream_error)
  43. );
  44. std::memcpy(address, &t, s);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement