Section hub

std::ranges::views::join, std::ranges::join_view

  1. A range adaptor that represents view consisting of the sequence obtained from flattening a view of ranges.

# Declarations

template< ranges::input_range V >
requires ranges::view<V> and
ranges::input_range<ranges::range_reference_t<V>>
class join_view
: public ranges::view_interface<join_view<V>>

(since C++20)

namespace views {
inline constexpr /* unspecified */ join = /* unspecified */;
}

(since C++20)

Call signature
template< ranges::viewable_range R >
requires /* see below */
constexpr ranges::view auto join( R&& r );

(since C++20)

# Notes

Before P2328R1 was adopted, the inner range type (ranges::range_reference_t) cannot be a container type (but can be reference to container). For example, it was not allowed to join a transform_view of std::string prvalue.

# Example

#include <iostream>
#include <ranges>
#include <string_view>
#include <vector>
 
int main()
{
    using namespace std::literals;
 
    const auto bits = {"https:"sv, "//"sv, "cppreference"sv, "."sv, "com"sv};
    for (char const c : bits | std::views::join)
        std::cout << c;
    std::cout << '\n';
 
    const std::vector<std::vector<int>> v{{1, 2}, {3, 4, 5}, {6}, {7, 8, 9}};
    auto jv = std::ranges::join_view(v);
    for (int const e : jv)
        std::cout << e << ' ';
    std::cout << '\n';
}

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 3474C++20views::join(e) returned a copy of e when e is a join_viewreturns a nested join_view
P2328R1C++20non-view range prvalues could not be joined by join_viewmade joinable

# 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