43.3 Error Indication by Stream Iterators

The istream and ostream iterators by themselves have no means of indicating the success or failure of an operation. The stream being operated on should be probed for good(), eof(), fail(), or bad() conditions. This is convenient, as stream state can be checked for exception conditions that were set in basic_ios (using the member function exceptions(iostate)) after each input or output operation.

Since stream buffers do not retain information about the success or failure of operations, streambuf iterators provide a member function, failed(), to indicate success or failure in a preceding operation on the stream buffer.