[ispanstream] # 31 Input/output library [[input.output]](./#input.output) ## 31.9 Span-based streams [[span.streams]](span.streams#ispanstream) ### 31.9.4 Class template basic_ispanstream [ispanstream] #### [31.9.4.1](#general) General [[ispanstream.general]](ispanstream.general) [🔗](#lib:basic_ispanstream) namespace std {template>class basic_ispanstream : public basic_istream {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; // [[ispanstream.cons]](#cons "31.9.4.2 Constructors"), constructorsexplicit basic_ispanstream(std::span s, ios_base::openmode which = ios_base::in); basic_ispanstream(const basic_ispanstream&) = delete; basic_ispanstream(basic_ispanstream&& rhs); template explicit basic_ispanstream(ROS&& s); basic_ispanstream& operator=(const basic_ispanstream&) = delete; basic_ispanstream& operator=(basic_ispanstream&& rhs); // [[ispanstream.swap]](#swap "31.9.4.3 Swap"), swapvoid swap(basic_ispanstream& rhs); // [[ispanstream.members]](#members "31.9.4.4 Member functions"), member functions basic_spanbuf* rdbuf() const noexcept; std::span span() const noexcept; void span(std::span s) noexcept; template void span(ROS&& s) noexcept; private: basic_spanbuf *sb*; // *exposition only*};} [1](#general-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10440) [*Note [1](#general-note-1)*: Constructing an ispanstream from a [*string-literal*](lex.string#nt:string-literal "5.13.5 String literals [lex.string]") includes the termination character '\0' in the underlying spanbuf[.](#general-1.sentence-1) — *end note*] #### [31.9.4.2](#cons) Constructors [[ispanstream.cons]](ispanstream.cons) [🔗](#lib:basic_ispanstream,constructor) `explicit basic_ispanstream(std::span s, ios_base::openmode which = ios_base::in); ` [1](#cons-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10455) *Effects*: Initializes the base class withbasic_istream(addressof(*sb*)) and *sb* withbasic_spanbuf(s, which | ios_base​::​in) ([[spanbuf.cons]](spanbuf.cons "31.9.3.2 Constructors"))[.](#cons-1.sentence-1) [🔗](#lib:basic_ispanstream,constructor_) `basic_ispanstream(basic_ispanstream&& rhs); ` [2](#cons-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10469) *Effects*: Initializes the base class with std​::​move(rhs) and *sb* with std​::​move(rhs.*sb*)[.](#cons-2.sentence-1) Next, basic_istream​::​set_rdbuf(addressof(*sb*)) is called to install the contained basic_spanbuf[.](#cons-2.sentence-2) [🔗](#lib:basic_ispanstream,constructor__) `template explicit basic_ispanstream(ROS&& s) ` [3](#cons-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10483) *Constraints*: ROS models ranges​::​[borrowed_range](range.range#concept:borrowed_range "25.4.2 Ranges [range.range]")[.](#cons-3.sentence-1) ![convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")> && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")> is true[.](#cons-3.sentence-2) [4](#cons-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10489) *Effects*: Let sp be std​::​span(std​::​forward(s))[.](#cons-4.sentence-1) Equivalent to:basic_ispanstream(std::span(const_cast(sp.data()), sp.size())) #### [31.9.4.3](#swap) Swap [[ispanstream.swap]](ispanstream.swap) [🔗](#lib:swap,basic_ispanstream) `void swap(basic_ispanstream& rhs); ` [1](#swap-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10506) *Effects*: Equivalent to:basic_istream::swap(rhs);*sb*.swap(rhs.*sb*); [🔗](#lib:swap,basic_ispanstream_) `template void swap(basic_ispanstream& x, basic_ispanstream& y); ` [2](#swap-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10522) *Effects*: Equivalent to x.swap(y)[.](#swap-2.sentence-1) #### [31.9.4.4](#members) Member functions [[ispanstream.members]](ispanstream.members) [🔗](#lib:rdbuf,basic_ispanstream) `basic_spanbuf* rdbuf() const noexcept; ` [1](#members-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10535) *Effects*: Equivalent to:return const_cast*>(addressof(*sb*)); [🔗](#lib:span,basic_ispanstream) `std::span span() const noexcept; ` [2](#members-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10549) *Effects*: Equivalent to: return rdbuf()->span(); [🔗](#lib:span,basic_ispanstream_) `void span(std::span s) noexcept; ` [3](#members-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10560) *Effects*: Equivalent to rdbuf()->span(s)[.](#members-3.sentence-1) [🔗](#members-itemdecl:4) `template void span(ROS&& s) noexcept; ` [4](#members-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10570) *Constraints*: ROS models ranges​::​[borrowed_range](range.range#concept:borrowed_range "25.4.2 Ranges [range.range]")[.](#members-4.sentence-1) (![convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")>) && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")> is true[.](#members-4.sentence-2) [5](#members-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L10576) *Effects*: Let sp be std​::​span(std​::​forward(s))[.](#members-5.sentence-1) Equivalent to:this->span(std::span(const_cast(sp.data()), sp.size()));