ostream_iterator<T>

An ostream_iterator is an iterator adapter that writes data to an output stream. Dereferencing and writing to an ostream_iterator uses the stream insertion operator >> to write data to the specified output stream.

ostream_iterator is a template type whose type argument is the type of element to write to the stream. For example, an ostream_iterator<int> writes ints to the stream.

Normally, ostream_iterators do not put any whitespace between the elements they write. You can change this behavior by setting a delimiter inside the ostream_iterator constructor.

ostream_iterator<T> Member Functions
ostream_iterator<T>(ostream &input)
Constructs an ostream_iterator that writes to the specified stream.
copy(v.begin(), v.end(), ostream_iterator<char>(cout)); //Copy v's elements to cout.

Constructs a new ostream_iterator that writes to the specified stream. No whitespace is inserted between elements.

ostream_iterator<T>(ostream &input, const char *delimiter)
Constructs a ostream_iterator that writes elements, followed by a delimiter, to the stream.
copy(v.begin(), v.end(), ostream_iterator<int>(cout, "\n")); //Copy v's elements to cout with a newline inserted between each element.

Constructs a new ostream_iterator that writes to the specified stream. The string delimiter is outputted to the stream after each element.