Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ranges::subrange<I,S,K>::subrange

      From cppreference.com
      <cpp‎ |ranges‎ |subrange
       
       
      Ranges library
      Range adaptors
       
       
      subrange() requiresstd::default_initializable<I>=default;
      (1)(since C++20)
      constexpr subrange(/*convertible-to-non-slicing*/<I>auto i, S s)
          requires(!/*StoreSize*/);
      (2)(since C++20)
      constexpr subrange(/*convertible-to-non-slicing*/<I>auto i, S s,

                         /*make-unsigned-like-t*/<std::iter_difference_t<I>> n)

          requires(K== ranges::subrange_kind::sized);
      (3)(since C++20)
      template</*different-from*/<subrange> R>

          requiresranges::borrowed_range<R>&&
                   /*convertible-to-non-slicing*/<ranges::iterator_t<R>, I>&&
                   std::convertible_to<ranges::sentinel_t<R>, S>
      constexpr subrange( R&& r)

          requires(!/*StoreSize*/||ranges::sized_range<R>);
      (4)(since C++20)
      template<ranges::borrowed_range R>

          requires/*convertible-to-non-slicing*/<ranges::iterator_t<R>, I>&&
                 std::convertible_to<ranges::sentinel_t<R>, S>
      constexpr subrange( R&& r,
                         /*make-unsigned-like-t*/<std::iter_difference_t<I>> n)
          requires(K== ranges::subrange_kind::sized)

         : subrange{ranges::begin(r),ranges::end(r), n}{}
      (5)(since C++20)

      Constructs asubrange.

      For the definitions of/*make-unsigned-like-t*/ and/*different-from*/, seemake-unsigned-like-t anddifferent-from respectively.

       Overload Data members
      begin_end_size_
      (only ifStoreSize istrue)
      (1)value-initializedvalue-initializedinitialized with0
      (2)initialized withstd::move(i)initialized withsN/A
      (3)initialized withn
      (4)initialized withstd::move(ranges::begin(r))initialized withranges::end(r)initialized withstatic_cast<decltype(size_ )>
          (ranges::size(r))
      (5)initialized withn
      2) If[is) is not avalid range, the behavior is undefined.
      3) If any of the following conditions is satisfied, the behavior is undefined:

      [edit]Parameters

      i - iterator that denotes the beginning of the range
      s - sentinel that denotes the end of the range
      r - range
      n - size hint, must be equal to the size of the range

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      P2393R1C++20for overload(4),size_ might be initialized withranges::size(r), but it is
      not always implicitly convertible to the correspondingunsigned-integer-like type
      made the
      conversion explicit
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/subrange/subrange&oldid=176926"

      [8]ページ先頭

      ©2009-2025 Movatter.jp