std::istream
has the prototype istream& read (char* s, streamsize n)
the actual number of bytes read should be gotten by calling istream::gcount()
, also the validity of the istream
can be known from ios::good
.
I was discussing another stream class' implementation I was trying to write with a colleague of mine, where I was saying I might follow this design; but he said instead of having the user call gcount everytime, one could have read's prototype like this istream& read (char* s, streamsize n, size_t &bytes_read)
so that it'll get over in a single call and the former is clumsier. I was unable to defend std
's design choice. What's the real rationale behind istream::read
?