#include <stlsoft/iterators/ostream_iterator.hpp>
This class template provides full backwards-compatibility with std::ostream_iterator, but offers the additional capability to supply both prefix and suffix to each delimited item.
For example, the following code indents each entry in the sequence as well as appending a carriage return.
std::vector<int> ints(10); { for(size_t i = 0; i < ints.size(); ++i) { ints[i] = i; }} std::cout << "Elements:" << std::endl; std::copy(ints.begin(), ints.end(), stlsoft::ostream_iterator<int>(std::cout, "\t", "\n"));
This gives the following output:
0 1 2 3 4 5 6 7 8
V | The value type. | |
C | The character type. Defaults to char . | |
T | The traits type. Defaults to std::char_traits<C> . | |
S | The string type. Defaults to std::basic_string<C> . |
Member Types | |
typedef V | assigned_type |
The value type. | |
typedef C | char_type |
The character type. | |
typedef T | traits_type |
The traits type. | |
typedef S | string_type |
The string type. | |
typedef std::basic_ostream < char_type, traits_type > | ostream_type |
The stream type. | |
typedef ostream_iterator< V, C, T, S > | class_type |
The class type. | |
Public Member Functions | |
Construction | |
ostream_iterator (ostream_type &os) | |
Constructs an instance holding a reference to the given stream, with default prefix and suffix. | |
template<typename S1> | |
ostream_iterator (ostream_type &os, S1 const &suffix) | |
Constructs an instance holding a reference to the given stream, with a suffix. | |
template<typename S1, typename S2> | |
ostream_iterator (ostream_type &os, S1 const &prefix, S2 const &suffix) | |
Constructs an instance holding a reference to the given stream, with a prefix and a suffix. | |
ostream_iterator (class_type const &rhs) | |
Creates a copy of an ostream_iterator instance. | |
Ouput Iterator Methods | |
deref_proxy | operator* () |
Dereference operator. | |
class_type & | operator++ () |
Pre-increment operator. | |
class_type & | operator++ (int) |
Post-increment operator. | |
Classes | |
class | deref_proxy |
typedef V assigned_type |
The value type.
typedef C char_type |
The character type.
typedef T traits_type |
The traits type.
typedef S string_type |
The string type.
typedef std:: basic_ostream< char_type , traits_type > ostream_type |
The stream type.
typedef ostream_iterator<V, C, T, S> class_type |
The class type.
ostream_iterator | ( | ostream_type & | os | ) | [inline, explicit] |
Constructs an instance holding a reference to the given stream, with default prefix and suffix.
ostream_iterator | ( | ostream_type & | os, | |
S1 const & | suffix | |||
) | [inline] |
Constructs an instance holding a reference to the given stream, with a suffix.
ostream_iterator | ( | ostream_type & | os, | |
S1 const & | prefix, | |||
S2 const & | suffix | |||
) | [inline] |
Constructs an instance holding a reference to the given stream, with a prefix and a suffix.
ostream_iterator | ( | class_type const & | rhs | ) | [inline] |
deref_proxy operator* | ( | ) | [inline] |
Dereference operator.
class_type& operator++ | ( | ) | [inline] |
Pre-increment operator.
class_type& operator++ | ( | int | ) | [inline] |
Post-increment operator.