29 Input/output library [input.output]

29.9 Span-based streams [span.streams]

29.9.4 Class template basic_­ispanstream [ispanstream]

29.9.4.1 General [ispanstream.general]

namespace std { template<class charT, class traits = char_traits<charT>> class basic_ispanstream : public basic_istream<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; // [ispanstream.ctor], constructors explicit basic_ispanstream(std::span<charT> s, ios_base::openmode which = ios_base::in); basic_ispanstream(const basic_ispanstream&) = delete; basic_ispanstream(basic_ispanstream&& rhs); template<class ROS> explicit basic_ispanstream(ROS&& s); // [ispanstream.assign], assignment and swap basic_ispanstream& operator=(const basic_ispanstream&) = delete; basic_ispanstream& operator=(basic_ispanstream&& rhs); void swap(basic_ispanstream& rhs); // [ispanstream.members], member functions basic_spanbuf<charT, traits>* rdbuf() const noexcept; std::span<const charT> span() const noexcept; void span(std::span<charT> s) noexcept; template<class ROS> void span(ROS&& s) noexcept; private: basic_spanbuf<charT, traits> sb; // exposition only }; template<class charT, class traits> void swap(basic_ispanstream<charT, traits>& x, basic_ispanstream<charT, traits>& y); }
[Note 1:
Constructing an ispanstream from a string-literal includes the termination character '\0' in the underlying spanbuf.
— end note]

29.9.4.2 Constructors [ispanstream.ctor]

explicit basic_ispanstream(std::span<charT> s, ios_base::openmode which = ios_base::in);
Effects: Initializes the base class with basic_­istream<charT, traits>(addressof(sb)) and sb with basic_­spanbuf<charT, traits>(s, which | ios_­base​::​in) ([spanbuf.ctor]).
basic_ispanstream(basic_ispanstream&& rhs);
Effects: Initializes the base class with std​::​move(rhs) and sb with std​::​move(rhs.sb).
Next, basic_­istream<charT, traits>​::​set_­rdbuf(addressof(sb)) is called to install the contained basic_­spanbuf.
template<class ROS> explicit basic_ispanstream(ROS&& s)
Constraints: ROS models ranges​::​borrowed_­range.
!convertible_­to<ROS, std​::​span<charT>> && convertible_­to<ROS, std​::​span<charT const>> is true.
Effects: Let sp be std​::​span<const charT>(std​::​forward<ROS>(s)).
Equivalent to basic_ispanstream(std::span<charT>(const_cast<charT*>(sp.data()), sp.size()))

29.9.4.3 Assignment and swap [ispanstream.assign]

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

29.9.4.4 Member functions [ispanstream.members]

basic_spanbuf<charT, traits>* rdbuf() const noexcept;
Effects: Equivalent to: return const_cast<basic_spanbuf<charT, traits>*>(addressof(sb));
std::span<const charT> span() const noexcept;
Effects: Equivalent to: return rdbuf()->span();
void span(std::span<charT> s) noexcept;
Effects: Equivalent to rdbuf()->span(s).
template<class ROS> void span(ROS&& s) noexcept;
Constraints: ROS models ranges​::​borrowed_­range.
(!convertible_­to<ROS, std​::​span<charT>>) && convertible_­to<ROS, std​::​span<const charT>> is true.
Effects: Let sp be std​::​span<const charT>(std​::​forward<ROS>(s)).
Equivalent to: this->span(std::span<charT>(const_cast<charT*>(sp.data()), sp.size()))