ostream_iterator Class Template Reference
[Iterators Library]

#include <stlsoft/iterators/ostream_iterator.hpp>

Inheritance diagram for ostream_iterator:

iterator_base< std::output_iterator_tag, void, void, void, void >

List of all members.


Detailed Description

template<typename V, typename C = char, typename T = std:: char_traits <C>, typename S = std:: basic_string <C, T>>
class stlsoft::ostream_iterator< V, C, T, S >

Enhanced functionality over std::ostream_iterator.

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

Parameters:
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>.
Remarks:
The class template avoids fatuous assignment syntax by using the Dereference Proxy pattern.
Examples:

by_library/windows_registry/enum_values/enum_values.cpp.


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_typeoperator++ ()
 Pre-increment operator.
class_typeoperator++ (int)
 Post-increment operator.

Classes

class  deref_proxy

Member Typedef Documentation

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.


Constructor & Destructor Documentation

ostream_iterator ( ostream_type os  )  [inline, explicit]

Constructs an instance holding a reference to the given stream, with default prefix and suffix.

Note:
This is 100% functionally compatible with std::ostream_iterator

ostream_iterator ( ostream_type os,
S1 const &  suffix 
) [inline]

Constructs an instance holding a reference to the given stream, with a suffix.

Note:
This is 100% functionally compatible with std::ostream_iterator

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]

Creates a copy of an ostream_iterator instance.

Parameters:
rhs The instance to copy


Member Function Documentation

deref_proxy operator* (  )  [inline]

Dereference operator.

class_type& operator++ (  )  [inline]

Pre-increment operator.

class_type& operator++ ( int   )  [inline]

Post-increment operator.


The documentation for this class was generated from the following file:

Generated on Thu Jun 10 08:58:48 2010 for STLSoft by  doxygen 1.5.6