9 Iterators library [iterators]

9.8 Stream iterators [iterators.stream]

9.8.4 Class template ostreambuf_iterator [ostreambuf.iterator]

namespace std { namespace experimental { namespace ranges { inline namespace v1 {
  template <class charT, class traits = char_traits<charT>>
  class ostreambuf_iterator {
  public:
    typedef ptrdiff_t                      difference_type;
    typedef charT                          char_type;
    typedef traits                         traits_type;
    typedef basic_streambuf<charT, traits> streambuf_type;
    typedef basic_ostream<charT, traits>   ostream_type;

    constexpr ostreambuf_iterator() noexcept;
    ostreambuf_iterator(ostream_type& s) noexcept;
    ostreambuf_iterator(streambuf_type* s) noexcept;
    ostreambuf_iterator& operator=(charT c);

    ostreambuf_iterator& operator*();
    ostreambuf_iterator& operator++();
    ostreambuf_iterator& operator++(int);
    bool failed() const noexcept;

  private:
    streambuf_type* sbuf_;                // exposition only
  };
}}}}

The class template ostreambuf_iterator writes successive characters onto the output stream from which it was constructed. It is not possible to get a character value out of the output iterator.

9.8.4.1 ostreambuf_iterator constructors [ostreambuf.iter.cons]

constexpr ostreambuf_iterator() noexcept;

Effects: Initializes sbuf_ with nullptr.

ostreambuf_iterator(ostream_type& s) noexcept;

Requires: s.rdbuf() != nullptr.

Effects: Initializes sbuf_ with s.rdbuf().

ostreambuf_iterator(streambuf_type* s) noexcept;

Requires: s != nullptr.

Effects: Initializes sbuf_ with s.

9.8.4.2 ostreambuf_iterator operations [ostreambuf.iter.ops]

ostreambuf_iterator& operator=(charT c);

Requires: sbuf_ != nullptr.

Effects: If failed() yields false, calls sbuf_->sputc(c); otherwise has no effect.

Returns: *this.

ostreambuf_iterator& operator*();

Returns: *this.

ostreambuf_iterator& operator++(); ostreambuf_iterator& operator++(int);

Returns: *this.

bool failed() const noexcept;

Requires: sbuf_ != nullptr.

Returns: true if in any prior use of member operator=, the call to sbuf_->sputc() returned traits::eof(); or false otherwise.