Files
2025-10-25 03:02:53 +03:00

4.1 KiB
Raw Permalink Blame History

[ostreambuf.iterator]

24 Iterators library [iterators]

24.6 Stream iterators [stream.iterators]

24.6.5 Class template ostreambuf_iterator [ostreambuf.iterator]

24.6.5.1 General [ostreambuf.iterator.general]

1

#

The class template ostreambuf_iterator writes successive characters onto the output stream from which it was constructed.

🔗

namespace std {template<class charT, class traits = char_traits>class ostreambuf_iterator {public:using iterator_category = output_iterator_tag; using value_type = void; using difference_type = ptrdiff_t; using pointer = void; using reference = void; using char_type = charT; using traits_type = traits; using streambuf_type = basic_streambuf<charT,traits>; using ostream_type = basic_ostream<charT,traits>;

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};}

24.6.5.2 Constructors [ostreambuf.iter.cons]

🔗

ostreambuf_iterator(ostream_type& s) noexcept;

1

#

Preconditions: s.rdbuf() is not a null pointer.

2

#

Effects: Initializes sbuf_ with s.rdbuf().

🔗

ostreambuf_iterator(streambuf_type* s) noexcept;

3

#

Preconditions: s is not a null pointer.

4

#

Effects: Initializes sbuf_ with s.

24.6.5.3 Operations [ostreambuf.iter.ops]

🔗

ostreambuf_iterator& operator=(charT c);

1

#

Effects: Iffailed() yieldsfalse, callssbuf_->sputc(c); otherwise has no effect.

2

#

Returns: *this.

🔗

ostreambuf_iterator& operator*();

3

#

Returns: *this.

🔗

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

4

#

Returns: *this.

🔗

bool failed() const noexcept;

5

#

Returns: true if in any prior use of memberoperator=, the call tosbuf_->sputc() returnedtraits::eof(); orfalse otherwise.