[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 basic_ospanstream : public basic_ostream {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 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* rdbuf() const noexcept; std::span span() const noexcept; void span(std::span s) noexcept; private: basic_spanbuf *sb*; // *exposition only*};} #### [31.9.5.2](#cons) Constructors [[ospanstream.cons]](ospanstream.cons) [🔗](#lib:basic_ospanstream,constructor) `explicit basic_ospanstream(std::span 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(addressof(*sb*)) and *sb* withbasic_spanbuf(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​::​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::swap(rhs);*sb*.swap(rhs.*sb*); [🔗](#lib:swap,basic_ospanstream_) `template void swap(basic_ospanstream& x, basic_ospanstream& 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* rdbuf() const noexcept; ` [1](#members-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10694) *Effects*: Equivalent to:return const_cast*>(addressof(*sb*)); [🔗](#lib:span,basic_ospanstream) `std::span 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 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)