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 ( void exceptions(iostate except_mask)) after each input or output operation.
void print() { ostream_iterator<int, char, char_traits<char> > os(cout); try { *os = 3; //output `3' os++; // receive next output } catch(ios_base::failure & emsg) { cerr<<emsg.what(); } }
The streambuf iterators provide a member function, failed(), to indicate success or failure in a preceding operation on the stream buffer.
OEM Edition, ©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.