Add explicit cast from streamsize, fixing MSVC warning

This commit is contained in:
Dmitry Marakasov 2016-05-23 18:38:18 +03:00
parent ceb85fd5cd
commit 8ab8772a1c

View File

@ -79,7 +79,11 @@ private:
template <class SS>
typename std::enable_if<std::is_base_of<std::istream, SS>::value, size_t>::type ReadHelper(void* ptr, size_t size, size_t maxnum) {
stream_.read(static_cast<char*>(ptr), size * maxnum);
size_t nread = stream_.gcount();
// http://en.cppreference.com/w/cpp/io/streamsize:
// "Except in the constructors of std::strstreambuf,
// negative values of std::streamsize are never used"
size_t nread = static_cast<size_t>(stream_.gcount());
// eof is OK
if (stream_.rdstate() == (std::ios_base::eofbit | std::ios_base::failbit))