std::ranges::views::join_with,std::ranges::join_with_view(3)

NAME
std::ranges::views::join_with,std::ranges::join_with_view - std::ranges::views::join_with,std::ranges::join_with_view

Synopsis
   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 (1) (since
                /* ranges::range_reference_t<V> and Pattern C++23)
                   have compatible elements (see below) */
   class join_with_view
       : ranges::view_interface<join_with_view<V, Pattern>>
   namespace views {
       inline constexpr /* unspecified */ join_with = /* unspecified (2) (since
   */; C++23)
   }
   Call signature
   template< ranges::viewable_range R, class Pattern >
                        (since
       requires /* see below */ C++23)
   constexpr ranges::view auto join_with( R&& r, Pattern&& pattern );
   template< class Pattern > (since
   constexpr /* range adaptor closure */ join_with( Pattern&& pattern 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:
     * std::common_with<ranges::range_value_t<ranges::range_reference_t<V>>,
                        ranges::range_value_t<Pattern>>
     * std::common_reference_with<ranges::range_reference_t<ranges::range_reference_t<V>>,
                        ranges::range_reference_t<Pattern>>
     * std::common_reference_with<ranges::range_rvalue_reference_t<ranges::range_reference_t<V>>,
                        ranges::range_rvalue_reference_t<Pattern>>
   join_with_view models input_range.
   join_with_view models forward_range when:
     * ranges::range_reference_t<V> is a reference, and
     * V and ranges::range_reference_t<V> each model forward_range.
   join_with_view models bidirectional_range when:
     * ranges::range_reference_t<V> is a reference,
     * V, ranges::range_reference_t<V>, and Pattern each models bidirectional_range,
       and
     * ranges::range_reference_t<V> and Pattern each model common_range.
   join_with_view models common_range when:
     * ranges::range_reference_t<V> is a reference, and
     * V and ranges::range_reference_t<V> each model forward_range and common_range.

Member functions
   constructor constructs a join_with_view
   (C++23) (public member function)
   base returns a copy of the underlying (adapted) view
   (C++23) (public member function)
   begin returns an iterator to the beginning
   (C++23) (public member function)
   end returns an iterator or a sentinel to the end
   (C++23) (public member function)
         Inherited from std::ranges::view_interface
   empty returns whether the derived view is empty. Provided if it satisfies
   (C++20) sized_range or forward_range.
                 (public member function of std::ranges::view_interface<D>)
   cbegin returns a constant iterator to the beginning of the range.
   (C++23) (public member function of std::ranges::view_interface<D>)
   cend returns a sentinel for the constant iterator of the range.
   (C++23) (public member function of std::ranges::view_interface<D>)
   operator bool returns whether the derived view is not empty. Provided if
   (C++20) ranges::empty is applicable to it.
                 (public member function of std::ranges::view_interface<D>)
   front returns the first element in the derived view. Provided if it
   (C++20) satisfies forward_range.
                 (public member function of std::ranges::view_interface<D>)
   back returns the last element in the derived view. Provided if it satisfies
   (C++20) bidirectional_range and common_range.
                 (public member function of std::ranges::view_interface<D>)
   Deduction guides
   Nested classes
   iterator the iterator type
   (C++23) (exposition-only member class template*)
   sentinel the sentinel type
   (C++23) (exposition-only member class template*)

Example
// Run this code
 #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.

See also
   ranges::join_view a view consisting of the sequence obtained from flattening a view
   views::join of ranges
   (C++20) (class template) (range adaptor object)