Section hub

std::ranges::views::istream, std::ranges::basic_istream_view, std::ranges::istream_view, std::ranges::wistream_view

  1. A range factory that generates a sequence of elements by repeatedly calling operator».

# Declarations

template< std::movable Val, class CharT,
class Traits = std::char_traits<CharT> >
requires std::default_initializable<Val> &&
/*stream-extractable*/<Val, CharT, Traits>
class basic_istream_view
: public ranges::view_interface<basic_istream_view<Val, CharT, Traits>>

(since C++20)

Helper templates
template< class Val >
using istream_view = ranges::basic_istream_view<Val, char>;

(since C++20)

template< class Val >
using wistream_view = ranges::basic_istream_view<Val, wchar_t>;

(since C++20)

Customization point objects
namespace views {
template< class T >
constexpr /* unspecified */ istream = /* unspecified */;
}

(since C++20)

Helper concepts
template< class Val, class CharT, class Traits >
concept /*stream-extractable*/ =
requires(std::basic_istream<CharT, Traits>& is, Val& t) {
is >> t;
};

(exposition only*)

# Example

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <ranges>
#include <sstream>
#include <string>
 
int main()
{
    auto words = std::istringstream{"today is yesterday’s tomorrow"};
    for (const auto& s : std::views::istream<std::string>(words))
        std::cout << std::quoted(s, '/') << ' ';
    std::cout << '\n';
 
    auto floats = std::istringstream{"1.1  2.2\t3.3\v4.4\f55\n66\r7.7  8.8"};
    std::ranges::copy
    (
        std::views::istream<float>(floats),
        std::ostream_iterator<float>{std::cout, ", "}
    );
    std::cout << '\n';
}

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 3568C++20P2325R3 accidentally made the stored value default-initializedrestored to value-initialization
P2325R3C++20default constructor was provided asview must be default_initializableremoved along withthe requirement
P2432R1C++20ranges::istream_view was a function templateand did not follow the naming conventionmade an alias template;customization point objects added

# See also

This hub groups the ranges library by user task rather than by raw reference tree shape. View types and adaptor objects are presented as the same conceptual item.

Core adapters

Start here for the adapters most people reach for first when building pipelines.

Utility views

These adapt shape, ownership, or projection rather than representing the “headline” pipeline steps.

New in C++23 / C++26

Newer adapters, kept as a compact scan list with only standard badges.

All entities by category

A lighter-weight index of the full ranges surface, grouped by conceptual task instead of raw page-tree names.

74 entities