109 lines
4.1 KiB
Markdown
109 lines
4.1 KiB
Markdown
[ospanstream]
|
||
|
||
# 31 Input/output library [[input.output]](./#input.output)
|
||
|
||
## 31.9 Span-based streams [[span.streams]](span.streams#ospanstream)
|
||
|
||
### 31.9.5 Class template basic_ospanstream [ospanstream]
|
||
|
||
#### [31.9.5.1](#general) General [[ospanstream.general]](ospanstream.general)
|
||
|
||
[ð](#lib:basic_ospanstream)
|
||
|
||
namespace std {template<class charT, class traits = char_traits<charT>>class basic_ospanstream : public basic_ostream<charT, traits> {public:using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; // [[ospanstream.cons]](#cons "31.9.5.2 Constructors"), constructorsexplicit basic_ospanstream(std::span<charT> s,
|
||
ios_base::openmode which = ios_base::out);
|
||
basic_ospanstream(const basic_ospanstream&) = delete;
|
||
basic_ospanstream(basic_ospanstream&& rhs);
|
||
|
||
basic_ospanstream& operator=(const basic_ospanstream&) = delete;
|
||
basic_ospanstream& operator=(basic_ospanstream&& rhs); // [[ospanstream.swap]](#swap "31.9.5.3 Swap"), swapvoid swap(basic_ospanstream& rhs); // [[ospanstream.members]](#members "31.9.5.4 Member functions"), member functions basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
||
|
||
std::span<charT> span() const noexcept; void span(std::span<charT> s) noexcept; private: basic_spanbuf<charT, traits> *sb*; // *exposition only*};}
|
||
|
||
#### [31.9.5.2](#cons) Constructors [[ospanstream.cons]](ospanstream.cons)
|
||
|
||
[ð](#lib:basic_ospanstream,constructor)
|
||
|
||
`explicit basic_ospanstream(std::span<charT> s,
|
||
ios_base::openmode which = ios_base::out);
|
||
`
|
||
|
||
[1](#cons-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10635)
|
||
|
||
*Effects*: Initializes the base class withbasic_ostream<charT, traits>(addressof(*sb*)) and *sb* withbasic_spanbuf<charT, traits>(s, which | ios_base::out) ([[spanbuf.cons]](spanbuf.cons "31.9.3.2 Constructors"))[.](#cons-1.sentence-1)
|
||
|
||
[ð](#lib:basic_ospanstream,constructor_)
|
||
|
||
`basic_ospanstream(basic_ospanstream&& rhs) noexcept;
|
||
`
|
||
|
||
[2](#cons-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10649)
|
||
|
||
*Effects*: Initializes the base class with std::move(rhs) and *sb* with std::move(rhs.*sb*)[.](#cons-2.sentence-1)
|
||
|
||
Next, basic_ostream<charT, traits>::set_rdbuf(addressof(*sb*)) is called to install the contained basic_spanbuf[.](#cons-2.sentence-2)
|
||
|
||
#### [31.9.5.3](#swap) Swap [[ospanstream.swap]](ospanstream.swap)
|
||
|
||
[ð](#lib:swap,basic_ospanstream)
|
||
|
||
`void swap(basic_ospanstream& rhs);
|
||
`
|
||
|
||
[1](#swap-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10665)
|
||
|
||
*Effects*: Equivalent to:basic_ostream<charT, traits>::swap(rhs);*sb*.swap(rhs.*sb*);
|
||
|
||
[ð](#lib:swap,basic_ospanstream_)
|
||
|
||
`template<class charT, class traits>
|
||
void swap(basic_ospanstream<charT, traits>& x, basic_ospanstream<charT, traits>& y);
|
||
`
|
||
|
||
[2](#swap-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10681)
|
||
|
||
*Effects*: Equivalent to x.swap(y)[.](#swap-2.sentence-1)
|
||
|
||
#### [31.9.5.4](#members) Member functions [[ospanstream.members]](ospanstream.members)
|
||
|
||
[ð](#lib:rdbuf,basic_ospanstream)
|
||
|
||
`basic_spanbuf<charT, traits>* rdbuf() const noexcept;
|
||
`
|
||
|
||
[1](#members-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10694)
|
||
|
||
*Effects*: Equivalent to:return const_cast<basic_spanbuf<charT, traits>*>(addressof(*sb*));
|
||
|
||
[ð](#lib:span,basic_ospanstream)
|
||
|
||
`std::span<charT> span() const noexcept;
|
||
`
|
||
|
||
[2](#members-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10708)
|
||
|
||
*Effects*: Equivalent to: return rdbuf()->span();
|
||
|
||
[ð](#lib:span,basic_ospanstream_)
|
||
|
||
`void span(std::span<charT> s) noexcept;
|
||
`
|
||
|
||
[3](#members-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10719)
|
||
|
||
*Effects*: Equivalent to rdbuf()->span(s)[.](#members-3.sentence-1)
|