mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-18 10:06:54 +01:00
f61c34b9c7
git-svn-id: https://cppannotations.svn.sourceforge.net/svnroot/cppannotations/trunk@432 f6dd340e-d3f9-0310-b409-bdd246841980
21 lines
1.2 KiB
Text
21 lines
1.2 KiB
Text
An hi(ostream_iterator)tt(ostream_iterator<Type>) adaptor
|
|
can be used to pass an hi(ostream: iterator)tt(ostream) to algorithms
|
|
expecting an OutputIterator. Two constructors are available for defining
|
|
tt(ostream_iterators):
|
|
verb(
|
|
ostream_iterator<Type> identifier(ostream &outStream);
|
|
ostream_iterator<Type> identifier(ostream &outStream, char const *delim);
|
|
)
|
|
tt(Type) is the type of the data elements that should be inserted into an
|
|
tt(ostream). It may be any type for which oplshift() is defined in
|
|
combinations with tt(ostream) objects. The latter constructor can be used to
|
|
separate the individual tt(Type) data elements by ti(delimiter) strings. The
|
|
former constructor does not use any delimiters.
|
|
|
|
The 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 use of tt(in.unsetf(ios::skipws)). It is used to clear the
|
|
hi(skipws)tt(ios::skipws) flag. As a consequence white space characters are
|
|
simply returned by the operator, and the file is copied character by
|
|
character. Here is the program:
|
|
verbinclude(stl/examples/ostreamiterator.cc)
|