Section hub

std::ranges::views::join_with, std::ranges::join_with_view

  1. A range adaptor that represents view consisting of the sequence obtained from flattening a view of ranges, with every element of the delimiter inserted in between elements of the view. The delimiter can be a single element or a view of elements.

# Declarations

template< ranges::input_range V, ranges::forward_range Pattern >
requires ranges::view<V> &&
ranges::input_range<ranges::range_reference_t<V>> &&
ranges::view<Pattern> &&
/*concatable*/<ranges::range_reference_t<V>, Pattern>
class join_with_view :
ranges::view_interface<join_with_view<V, Pattern>>

(since C++23)

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

(since C++23)

Call signature
template< ranges::viewable_range R, class Pattern >
requires /* see below */
constexpr ranges::view auto join_with( R&& r, Pattern&& pattern );

(since C++23)

template< class Pattern >
constexpr /* range adaptor closure */ join_with( Pattern&& pattern );

(since C++23)

# Notes

Feature-test macro Value Std Feature __cpp_lib_ranges_join_with 202202L (C++23) std::ranges::join_with_view

# Example

#include <iostream>
#include <ranges>
#include <string_view>
#include <vector>
 
int main()
{
    using namespace std::literals;
 
    std::vector v{"This"sv, "is"sv, "a"sv, "test."sv};
    auto joined = v | std::views::join_with(' ');
 
    for (auto c : joined)
        std::cout << c;
    std::cout << '\n';
}

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 4074C++23join_with_view was underconstrainedupdated the constraints

# 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