Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

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

      From cppreference.com
      <cpp‎ |ranges
       
       
      Ranges library
      Range adaptors
       
       
      Defined in header<ranges>
      template<ranges::input_range V,ranges::forward_range Pattern>

        requiresranges::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>>
      (1)(since C++23)
      namespace views{

         inlineconstexpr/* unspecified */ join_with=/* unspecified */;

      }
      (2)(since C++23)
      Call signature
      template<ranges::viewable_range R,class Pattern>

          requires/* see below */

      constexprranges::viewauto 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 representsview 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.
      For the definition of/*concatable*/, seestd::ranges::concat_view.
      2)RangeAdaptorObject. The expressionviews::join_with(e, f) isexpression-equivalent tojoin_with_view(e, f) for any suitable subexpressionse andf.

      join_with_view modelsinput_range.

      join_with_view modelsforward_range when:

      join_with_view modelsbidirectional_range when:

      join_with_view modelscommon_range when:

      Contents

      [edit]Nested types

      Type Definition
      InnerRngranges::range_reference_t<V>
      (exposition-only member type*)

      [edit]Data members

      Member Definition
      Vbase_ the underlying (adapted) view
      (exposition-only member object*)
      Patternpattern_ the pattern object
      (exposition-only member object*)
      non-propagating-cache <ranges::iterator_t<V>>outer_it_
      (present only ifV does not modelforward_range)
      the cache of the outer iterator
      (exposition-only member object*)
      non-propagating-cache <std::remove_cv_t<InnerRng >>inner_
      (present only ifstd::is_reference_v<InnerRng > isfalse)
      the cache of the inner range
      (exposition-only member object*)

      [edit]Member functions

      constructs ajoin_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 fromstd::ranges::view_interface
      returns whether the derived view is empty, provided only if it satisfiessized_range orforward_range
      (public member function ofstd::ranges::view_interface<D>)[edit]
      (C++23)
      returns a constant iterator to the beginning of the range
      (public member function ofstd::ranges::view_interface<D>)[edit]
      (C++23)
      returns a sentinel for the constant iterator of the range
      (public member function ofstd::ranges::view_interface<D>)[edit]
      returns whether the derived view is not empty, provided only ifranges::empty is applicable to it
      (public member function ofstd::ranges::view_interface<D>)[edit]
      returns the first element in the derived view, provided if it satisfiesforward_range
      (public member function ofstd::ranges::view_interface<D>)[edit]
      returns the last element in the derived view, provided only if it satisfiesbidirectional_range andcommon_range
      (public member function ofstd::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 macroValueStdFeature
      __cpp_lib_ranges_join_with202202L(C++23)std::ranges::join_with_view

      [edit]Example

      Run this code
      #include <iostream>#include <ranges>#include <string_view>#include <vector> int main(){usingnamespace 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]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

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

      [edit]See also

      aview consisting of the sequence obtained from flattening aview ofranges
      (class template)(range adaptor object)[edit]
      aview consisting of concatenation of the adapted views
      (class template)(customization point object)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/join_with_view&oldid=176579"

      [8]ページ先頭

      ©2009-2025 Movatter.jp