ostream_iterator Class

The template class ostream_iterator describes an output iterator object that writes successive elements onto the output stream with the extraction operator <<.

template < 
   class Type  
   class CharType = char 
   class Traits = char_traits<CharType> 
> 
class ostream_iterator

Parameters

  • Type
    The type of object to be inserted into the output stream.

  • CharType
    The type that represents the character type for the ostream_iterator. This argument is optional and the default value is char*.*

  • Traits
    The type that represents the character type for the ostream_iterator. This argument is optional and the default value is char_traits<CharType>.

The ostream_iterator class must satisfy the requirements for an output iterator. Algorithms can be written directly to output streams using an ostream_iterator.

Constructors

ostream_iterator

Constructs an ostream_iterator that is initialized and delimited to write to the output stream.

Typedefs

char_type

A type that provides for the character type of the ostream_iterator.

ostream_type

A type that provides for the stream type of the ostream_iterator.

traits_type

A type that provides for the character traits type of the ostream_iterator.

Operators

operator*

Dereferencing operator used to implement the output iterator expression *i = x.

operator++

A nonfunctional increment operator that returns an ostream_iterator to the same object it addressed before the operation was called.

operator=

Assignment operator used to implement the output iterator expression *i = x for writing to an output stream.

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

<iterator>

Thread Safety in the C++ Standard Library

Standard Template Library