cppannotations/yo/stl/ostreamiterators.yo
fbbrokken 6881bc3814 The trunk directory contains the latest version (6.4.0c) of the C++
Annotations. 

The branches and tags directory are empty, since I couldn't
svnadmin import a repostitory dump. Many earlier versions exist, though, and
if you want the full archive, just let me know and I'll send you the svnadmin
dump of my full C++ Annotations archive.

Frank B. Brokken <f.b.brokken@rug.nl>



git-svn-id: https://cppannotations.svn.sourceforge.net/svnroot/cppannotations/trunk@3 f6dd340e-d3f9-0310-b409-bdd246841980
2006-09-04 08:26:34 +00:00

26 lines
1.4 KiB
Text

The ti(ostream_iterator<Type>()) can be used to define a destination iterator
for an ti(ostream) object. The general forms
of the tt(ostream_iterator<Type>()) iterator are:
verb(
ostream_iterator<Type> identifier(ostream &outStream), // and:
ostream_iterator<Type> identifier(ostream &outStream, char const *delim);
)
tt(Type) is the type of the data elements that should be written to the
tt(ostream) stream. tt(Type) may be any type for which oplshift() is defined
in combinations with tt(ostream) objects. The latter form of the
tt(ostream_iterators) separates the individual tt(Type) data elements by
ti(delimiter) strings. The former definition does not use any delimiters.
The following example shows how
link(tt(istream_iterators))(ISTREAMITERATORS) and an tt(ostream_iterator) may
be used to copy information of a file to another file. A subtlety is the
statement tt(in.unsetf(ios::skipws)): it resets the ti(ios::skipws) flag. The
consequence of this is that the default behavior of oprshift(), to skip
whitespace, is modified. White space characters are simply returned by the
operator, and the file is copied unrestrictedly. Here is the program:
verbinclude(stl/cc/ostreamiterator.cc)
Before tt(ostream_iterators) can be used the following preprocessor
directive must have been specified: hi(#include <iterator>)
verb(
#include <iterator>
)