Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | ranges
 
 
Ranges library
Range access
Range conversions
(C++23)

Range primitives



Dangling iterator handling
Range concepts
Views

Range factories
Range adaptors
Range generators
Range adaptor objects
Range adaptor closure objects
Helper items
(until C++23)(C++23)


 
 
Defined in header <ranges>
template< ranges::input_range V, ranges::forward_range Pattern >

    requires ranges::view<V> and
             ranges::input_range<ranges::range_reference_t<V>> and
             ranges::view<Pattern> and
             /* ranges::range_reference_t<V> and Pattern
                have compatible elements (see below) */

class join_with_view

    : ranges::view_interface<join_with_view<V, Pattern>>
(1) (since C++23)
namespace views {

    inline constexpr /* unspecified */ join_with = /* unspecified */;

}
(2) (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)
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.
2) RangeAdaptorObject. The expression views::join_with(e, f) is expression-equivalent to join_with_view(e, f) for any suitable subexpressions e and f.

ranges::range_reference_t<V> and Pattern have compatible elements if all of the following concepts are modeled:

join_with_view models input_range.

join_with_view models forward_range when:

join_with_view models bidirectional_range when:

join_with_view models common_range when:

Contents

[edit] Member types

Name Description
InnerRng (private) ranges::range_reference_t<V>
(exposition-only member type*)

[edit] Data members

Member name Definition
base_ (private) the underlying (adapted) view of type V
(exposition-only member object*)
pattern_ (private) the pattern object of type Pattern
(exposition-only member object*)
outer-it_ (private)
(conditionally present)
an optional-like object of type /*non-propagating-cache*/<ranges::iterator_t<V>> that caches the outer iterator; present only if V does not model forward_range
(exposition-only member object*)
inner_ (private)
(conditionally present)
an optional-like object of type /*non-propagating-cache*/<std::remove_cv_t</*InnerRng*/>> that caches the inner range; present only if std::is_reference_v<InnerRng> is false
(exposition-only member object*)

[edit] Member functions

constructs a join_with_view
(public member function) [edit]
returns a copy of the underlying (adapted) view
(public member function) [edit]
returns an iterator to the beginning
(public member function) [edit]
returns an iterator or a sentinel to the end
(public member function) [edit]
Inherited from std::ranges::view_interface
returns whether the derived view is empty. Provided if it satisfies sized_range or forward_range.
(public member function of std::ranges::view_interface<D>) [edit]
(C++23)
returns a constant iterator to the beginning of the range.
(public member function of std::ranges::view_interface<D>) [edit]
(C++23)
returns a sentinel for the constant iterator of the range.
(public member function of std::ranges::view_interface<D>) [edit]
returns whether the derived view is not empty. Provided if ranges::empty is applicable to it.
(public member function of std::ranges::view_interface<D>) [edit]
returns the first element in the derived view. Provided if it satisfies forward_range.
(public member function of std::ranges::view_interface<D>) [edit]
returns the last element in the derived view. Provided if it satisfies bidirectional_range and common_range.
(public member function of std::ranges::view_interface<D>) [edit]

[edit] Deduction guides

[edit] Nested classes

the iterator type
(exposition-only member class template*)
the sentinel type
(exposition-only member class template*)

[edit] Notes

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

[edit] 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';
}

Output:

This is a test.

[edit] See also

a view consisting of the sequence obtained from flattening a view of ranges
(class template) (range adaptor object)[edit]
a view consisting of concatenation of the adapted views
(class template) (customization point object)[edit]