In contrast to regular container iterators, stream iterators can provide only non-modifiable read-only access or write-only access to their elements. The istream_iterator is a read-only iterator that can access but not modify elements by assignment. The ostream_iterator,on the other hand, provides write-only access to streams.
Each time the istream_iterator invokes operator++, a new value from the stream is read and stored in a const T value, where T is the type of the element being written. The const value, which by definition cannot be overwritten by assignment, is then available through the use of the dereferencing operator *. This behavior of storing elements in the iterator is unique to istream_iterators.
Also unlike container iterators, stream iterators can access elements only once, and only in the forward-moving direction, so that they can work only with one-pass algorithms. If the contents of the stream are to be read more than once, separate iterators must be created for each pass.
The istream_iterator has a template argument Distance, which is defined as ptrdiff_t but not used in the implementation. There is no distance type template argument for ostream_iterator, so it does not have the notion of distance!
OEM Edition, ©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.