ostream_iterator writes (using operator<<) successive elements onto the output stream from which it was constructed. If it was constructed with charT* as a constructor argument, this string, called a delimiter string, is written to the stream after every T is written. It is not possible to get a value out of the output iterator. Its only use is as an output iterator in situations like
while (first != last) *result++ = *first++;
ostream_iterator is defined as:
namespace std { namespace experimental { namespace ranges { inline namespace v1 { template <class T, class charT = char, class traits = char_traits<charT>> class ostream_iterator { public: typedef ptrdiff_t difference_type; typedef charT char_type; typedef traits traits_type; typedef basic_ostream<charT, traits> ostream_type; constexpr ostream_iterator() noexcept; ostream_iterator(ostream_type& s) noexcept; ostream_iterator(ostream_type& s, const charT* delimiter) noexcept; ostream_iterator(const ostream_iterator& x) noexcept; ~ostream_iterator(); ostream_iterator& operator=(const T& value); ostream_iterator& operator*(); ostream_iterator& operator++(); ostream_iterator& operator++(int); private: basic_ostream<charT, traits>* out_stream; // exposition only const charT* delim; // exposition only }; }}}}
constexpr ostream_iterator() noexcept;
Effects: Initializes out_stream and delim with nullptr.
ostream_iterator(ostream_type& s) noexcept;
Effects: Initializes out_stream with &s and delim with nullptr.
ostream_iterator(ostream_type& s, const charT* delimiter) noexcept;
Effects: Initializes out_stream with &s and delim with delimiter.
ostream_iterator(const ostream_iterator& x) noexcept;
Effects: Constructs a copy of x.
Effects: The iterator is destroyed.
ostream_iterator& operator=(const T& value);
Effects: Equivalent to:
*out_stream << value; if(delim != nullptr) *out_stream << delim; return *this;
ostream_iterator& operator*();
Returns: *this.
ostream_iterator& operator++();
ostream_iterator& operator++(int);
Returns: *this.