24 Ranges library [ranges]

24.6 Range factories [range.factories]

24.6.5 Istream view [range.istream]

24.6.5.2 Class template basic_­istream_­view [range.istream.view]

namespace std::ranges { template<class Val, class CharT, class Traits> concept stream-extractable = // exposition only requires(basic_istream<CharT, Traits>& is, Val& t) { is >> t; }; template<movable Val, class CharT, class Traits> requires default_initializable<Val> && stream-extractable<Val, CharT, Traits> class basic_istream_view : public view_interface<basic_istream_view<Val, CharT, Traits>> { public: basic_istream_view() = default; constexpr explicit basic_istream_view(basic_istream<CharT, Traits>& stream); constexpr auto begin() { if (stream_) { *stream_ >> object_; } return iterator{*this}; } constexpr default_sentinel_t end() const noexcept; private: struct iterator; // exposition only basic_istream<CharT, Traits>* stream_ = nullptr; // exposition only Val object_ = Val(); // exposition only }; }
constexpr explicit basic_istream_view(basic_istream<CharT, Traits>& stream);
Effects: Initializes stream_­ with addressof(stream).
constexpr default_sentinel_t end() const noexcept;
Effects: Equivalent to: return default_­sentinel;
template<class Val, class CharT, class Traits> basic_istream_view<Val, CharT, Traits> istream_view(basic_istream<CharT, Traits>& s);
Effects: Equivalent to: return basic_­istream_­view<Val, CharT, Traits>{s};