122 lines
4.1 KiB
Markdown
122 lines
4.1 KiB
Markdown
[ostreambuf.iterator]
|
||
|
||
# 24 Iterators library [[iterators]](./#iterators)
|
||
|
||
## 24.6 Stream iterators [[stream.iterators]](stream.iterators#ostreambuf.iterator)
|
||
|
||
### 24.6.5 Class template ostreambuf_iterator [ostreambuf.iterator]
|
||
|
||
#### [24.6.5.1](#general) General [[ostreambuf.iterator.general]](ostreambuf.iterator.general)
|
||
|
||
[1](#general-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7091)
|
||
|
||
The class template ostreambuf_iterator writes successive *characters* onto the output stream
|
||
from which it was constructed[.](#general-1.sentence-1)
|
||
|
||
[ð](#lib:ostreambuf_iterator)
|
||
|
||
namespace std {template<class charT, class traits = char_traits<charT>>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](#ostreambuf.iter.cons) Constructors [[ostreambuf.iter.cons]](ostreambuf.iter.cons)
|
||
|
||
[ð](#lib:ostreambuf_iterator,constructor)
|
||
|
||
`ostreambuf_iterator(ostream_type& s) noexcept;
|
||
`
|
||
|
||
[1](#ostreambuf.iter.cons-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7135)
|
||
|
||
*Preconditions*: s.rdbuf() is not a null pointer[.](#ostreambuf.iter.cons-1.sentence-1)
|
||
|
||
[2](#ostreambuf.iter.cons-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7140)
|
||
|
||
*Effects*: Initializes sbuf_ with s.rdbuf()[.](#ostreambuf.iter.cons-2.sentence-1)
|
||
|
||
[ð](#lib:ostreambuf_iterator,constructor_)
|
||
|
||
`ostreambuf_iterator(streambuf_type* s) noexcept;
|
||
`
|
||
|
||
[3](#ostreambuf.iter.cons-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7151)
|
||
|
||
*Preconditions*: s is not a null pointer[.](#ostreambuf.iter.cons-3.sentence-1)
|
||
|
||
[4](#ostreambuf.iter.cons-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7156)
|
||
|
||
*Effects*: Initializes sbuf_ with s[.](#ostreambuf.iter.cons-4.sentence-1)
|
||
|
||
#### [24.6.5.3](#ostreambuf.iter.ops) Operations [[ostreambuf.iter.ops]](ostreambuf.iter.ops)
|
||
|
||
[ð](#lib:operator=,ostreambuf_iterator)
|
||
|
||
`ostreambuf_iterator& operator=(charT c);
|
||
`
|
||
|
||
[1](#ostreambuf.iter.ops-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7169)
|
||
|
||
*Effects*: Iffailed() yieldsfalse,
|
||
callssbuf_->sputc(c);
|
||
otherwise has no effect[.](#ostreambuf.iter.ops-1.sentence-1)
|
||
|
||
[2](#ostreambuf.iter.ops-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7179)
|
||
|
||
*Returns*: *this[.](#ostreambuf.iter.ops-2.sentence-1)
|
||
|
||
[ð](#lib:operator*,ostreambuf_iterator)
|
||
|
||
`ostreambuf_iterator& operator*();
|
||
`
|
||
|
||
[3](#ostreambuf.iter.ops-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7190)
|
||
|
||
*Returns*: *this[.](#ostreambuf.iter.ops-3.sentence-1)
|
||
|
||
[ð](#lib:operator++,ostreambuf_iterator)
|
||
|
||
`ostreambuf_iterator& operator++();
|
||
ostreambuf_iterator& operator++(int);
|
||
`
|
||
|
||
[4](#ostreambuf.iter.ops-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7202)
|
||
|
||
*Returns*: *this[.](#ostreambuf.iter.ops-4.sentence-1)
|
||
|
||
[ð](#lib:failed,ostreambuf_iterator)
|
||
|
||
`bool failed() const noexcept;
|
||
`
|
||
|
||
[5](#ostreambuf.iter.ops-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L7213)
|
||
|
||
*Returns*: true if in any prior use of memberoperator=,
|
||
the call tosbuf_->sputc() returnedtraits::eof();
|
||
orfalse otherwise[.](#ostreambuf.iter.ops-5.sentence-1)
|