29 Input/output library [input.output]

29.9 Span-based streams [span.streams]

29.9.6 Class template basic_­spanstream [spanstream]

29.9.6.1 General [spanstream.general]

namespace std { template<class charT, class traits = char_traits<charT>> class basic_spanstream : public basic_iostream<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; // [spanstream.ctor], constructors explicit basic_spanstream(std::span<charT> s, ios_base::openmode which = ios_base::out | ios_base::in); basic_spanstream(const basic_spanstream&) = delete; basic_spanstream(basic_spanstream&& rhs); // [spanstream.assign], assignment and swap basic_spanstream& operator=(const basic_spanstream&) = delete; basic_spanstream& operator=(basic_spanstream&& rhs); void swap(basic_spanstream& rhs); // [spanstream.members], members 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 }; template<class charT, class traits> void swap(basic_spanstream<charT, traits>& x, basic_spanstream<charT, traits>& y); }

29.9.6.2 Constructors [spanstream.ctor]

explicit basic_spanstream(std::span<charT> s, ios_base::openmode which = ios_base::out | ios_bas::in);
Effects: Initializes the base class with basic_­ostream<charT, traits>(addressof(sb)) and sb with basic_­spanbuf<charT, traits>(s, which) ([spanbuf.ctor]).
basic_spanstream(basic_spanstream&& rhs);
Effects: Initializes the base class with std​::​move(rhs) and sb with std​::​move(rhs.sb).
Next, basic_­iostream<charT, traits>​::​set_­rdbuf(addressof(sb)) is called to install the contained basic_­spanbuf.

29.9.6.3 Assignment and swap [spanstream.assign]

void swap(basic_spanstream& rhs);
Effects: Equivalent to: basic_iostream<charT, traits>::swap(rhs); sb.swap(rhs.sb);
template<class charT, class traits> void swap(basic_spanstream<charT, traits>& x, basic_spanstream<charT, traits>& y);
Effects: Equivalent to x.swap(y).

29.9.6.4 Member functions [spanstream.members]

basic_spanbuf<charT, traits>* rdbuf() const noexcept;
Effects: Equivalent to: return const_cast<basic_spanbuf<charT, traits>*>(addressof(sb));
std::span<charT> span() const noexcept;
Effects: Equivalent to: return rdbuf()->span();
void span(std::span<charT> s) noexcept;
Effects: Equivalent to rdbuf()->span(s).