From cppreference.com
Defined in header
template<ranges::input_rangeV,ranges::forward_rangePattern>requiresranges::view<V>&&ranges::input_range<ranges::range_reference_t<V>>&&ranges::view<Pattern>&&/*concatable*/<ranges::range_reference_t<V>,Pattern>classjoin_with_view:ranges::view_interface<join_with_view<V,Pattern>> (1) (since C++23)namespaceviews{inlineconstexpr/* unspecified */join_with=/* unspecified */;} (2) (since C++23)Call signature
template<ranges::viewable_rangeR,classPattern>requires/* see below */constexprranges::viewautojoin_with(R&&r,Pattern&&pattern);(since C++23)template<classPattern>constexpr/* range adaptor closure */join_with(Pattern&&pattern);(since C++23)1) A range adaptor that represents
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.
join_with_view models
.
join_with_view models
when:
ranges::range_reference_t<V> is a reference, and
V and ranges::range_reference_t<V> each model
.
join_with_view models
when:
ranges::range_reference_t<V> is a reference,
V, ranges::range_reference_t<V>, and Pattern each models
, and
ranges::range_reference_t<V> and Pattern each model
.
join_with_view models
when:
ranges::range_reference_t<V> is a reference, and
V and ranges::range_reference_t<V> each model
and
.
Nested types
Type Definition InnerRngranges::range_reference_t<V>
(exposition-only member type*)Data members
Member Description Vbase_the underlying (adapted) view
(exposition-only member object*)Patternpattern_the pattern object
(exposition-only member object*)
<ranges::iterator_t<V>>outer_it_
(present only if V does not model
)the cache of the outer iterator
(exposition-only member object*)
<std::remove_cv_t<InnerRng>>inner_
(present only if std::is_reference_v<InnerRng> is false)the cache of the inner range
(exposition-only member object*)Member functions
constructs a join_with_view
(public member function)
returns a copy of the underlying (adapted) view
(public member function)
returns an iterator to the beginning
(public member function)
returns an iterator or a sentinel to the end
(public member function)
Inherited from
returns whether the derived view is empty, provided only if it satisfies
or
(public member function of std::ranges::view_interface<D>)
(C++23)
returns a constant iterator to the beginning of the range
(public member function of std::ranges::view_interface<D>)
(C++23)
returns a sentinel for the constant iterator of the range
(public member function of std::ranges::view_interface<D>)
returns whether the derived view is not empty, provided only if
is applicable to it
(public member function of std::ranges::view_interface<D>)
returns the first element in the derived view, provided if it satisfies
(public member function of std::ranges::view_interface<D>)
returns the last element in the derived view, provided only if it satisfies
and
(public member function of std::ranges::view_interface<D>)
Nested classes
the iterator type
(exposition-only member class template*)the sentinel type
(exposition-only member class template*)Notes
macro ValueStdFeature
(C++23)std::ranges::join_with_viewExample
Run this code
#include<print>#include<ranges>#include<string_view>#include<list>intmain(){std::list<std::string_view>v{"_","cpp","lib","ranges","join","with"};std::println("{:s}",v|std::views::join_with('_'));}Output:
__cpp_lib_ranges_join_with Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior
C++23 join_with_view was underconstrained updated the constraints See also