Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

ostream_iterator


Iterator

Summary

Stream iterators allow for use of iterators with ostreams and istreams. They allow generic algorithms to be used directly on streams.

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <ostream>
template <class T, class charT, 
          class traits = char_traits<charT> >
class ostream_iterator 
 : public iterator<output_iterator_tag,void,void>;

Description

Stream iterators use the standard iterator interface for input and output streams.

The class ostream_iterator writes elements to an output stream. If you use the constructor that has a second char * argument, then that string is written after every element (the string must be null-terminated). Since an ostream iterator is an output iterator, it is not possible to get an element out of the iterator. You can only assign to it.

Interface

template <class T, class charT, 
          class traits = char_traits<charT> >
 class ostream_iterator  
   : public iterator<output_iterator_tag,void,void> 
{
 public:
    ostream_iterator(ostream&);
    ostream_iterator (ostream&, const char*); 
    ostream_iterator (const 
            ostream_iterator<T,charT,char_traits<charT> >&);
    ~ostream_itertor ();
    ostream_iterator<T,charT,char_traits<charT> >& 
         operator=(const T&);
    ostream_iterator<T,charT,char_traits<charT> >& 
         operator* () const;
    ostream_iterator<T,charT,char_traits<charT> >&
         operator++ ();
    ostream_iterator<T,charT,char_traits<charT> > 
         operator++ (int);
 };

Types

value_type; 
char_type; 
traits_type; 
ostream_type; 

Constructors

ostream_iterator (ostream& s);
ostream_iterator (ostream& s, const char* delimiter);
ostream_iterator (const ostream_iterator<T>& x);

Destructors

~ostream_iterator ();

Operators

const T& 
operator= (const T& value);
const T& ostream_iterator<T>& 
operator* ();
ostream_iterator<T>&  
operator++();
ostream_iterator<T>
operator++ (int);

Example

Warnings

If your compiler does not support default template parameters, then you always need to supply the Allocator template argument. For instance, you need to write:

deque<int, allocator<int> >

instead of:

deque<int>

If your compiler does not support namespaces, then you do not need the using declaration for std.

See Also

istream_iterator, Iterators



Previous fileTop of documentContentsIndexNext file
©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.
OEM Release, June 1998