1、istream_iterator 对象上的操作
- istream_iterator in_iter(cin); // read ints from cin
- istream_iterator eof; // istream "end" iterator
- // read until end of file, storing what was read in vec
- while (in_iter != eof)
- // increment advances the stream to the next value
- // dereference reads next value from the istream
- vec.push_back(*in_iter++);
- istream_iterator in_iter(cin); // read ints from cin
- istream_iterator eof; // istream "end" iterator
- vector vec(in_iter, eof); // construct vec from an iterator range
- // write one string per line to the standard output
- ostream_iterator out_iter(cout, "\n");
- // read strings from standard input and the end iterator
- istream_iterator in_iter(cin), eof;
- // read until eof and write what was read to the standard output
- while (in_iter != eof)
- // write value of in_iter to standard output
- // and then increment the iterator to get the next value from cin
- *out_iter++ = *in_iter++;