From 8ab8772a1cfc4d216ca6003ce230356ec2fe4882 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Mon, 23 May 2016 18:38:18 +0300 Subject: [PATCH] Add explicit cast from streamsize, fixing MSVC warning --- SDL2pp/StreamRWops.hh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SDL2pp/StreamRWops.hh b/SDL2pp/StreamRWops.hh index e84a0c3..4530eda 100644 --- a/SDL2pp/StreamRWops.hh +++ b/SDL2pp/StreamRWops.hh @@ -79,7 +79,11 @@ private: template typename std::enable_if::value, size_t>::type ReadHelper(void* ptr, size_t size, size_t maxnum) { stream_.read(static_cast(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(stream_.gcount()); // eof is OK if (stream_.rdstate() == (std::ios_base::eofbit | std::ios_base::failbit))