Jason said:
Oops. This contradicts what I just wrote.
Eh... I may not be entirely correct there either. Read 27.6.2.5.3 for me,
will you? It says (and I quote):
~~~~~
basic_ostream<charT,traits>& operator<<
(basic_streambuf<charT,traits>* sb);
6 Effects: If sb is null calls setstate(badbit) (which may throw
ios_base::failure).
7 Gets characters from sb and inserts them in *this. Characters are
read from sb and inserted until any of the following occurs:
— end-of-file occurs on the input sequence;
— inserting in the output sequence fails (in which case the character
to be inserted is not extracted);
— an exception occurs while getting a character from sb.
8 If the function inserts no characters, it calls setstate(failbit)
(which may throw ios_base::failure (27.4.4.3)). If an exception was
thrown while extracting a character, the function set failbit in
error state, and if failbit is on in exceptions() the caught
exception is rethrown.
9 Returns: *this.
~~~~~
Now, I think what I said about failing to read falls under the last bullet
item in paragraph 7. But if no exception is thrown, and the buffer goes
bad after reading and inserting several characters, the operation will be
flagged as successful, I guess.
That's where I'm wrong, probably. You still need to test 'in' when
returning the flag. Or not. Depending on what you consider a failure.
V