namespace std::ranges {
template<class Val, class CharT, class Traits>
concept stream-extractable =
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;
basic_istream<CharT, Traits>* stream_ = nullptr;
Val object_ = Val();
};
}
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};