Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      deduction guides forstd::ranges::subrange

      From cppreference.com
      <cpp‎ |ranges‎ |subrange
       
       
      Ranges library
      Range adaptors
       
       
      Defined in header<ranges>
      template<std::input_or_output_iterator I,std::sentinel_for<I> S>
      subrange(I, S)-> subrange<I, S>;
      (1)(since C++20)
      template<std::input_or_output_iterator I,std::sentinel_for<I> S>

      subrange(I, S,/*make-unsigned-like-t*/<std::iter_difference_t<I>>)->

          subrange<I, S, ranges::subrange_kind::sized>;
      (2)(since C++20)
      template<ranges::borrowed_range<R>>

      subrange(R&&)->
          subrange<ranges::iterator_t<R>,ranges::sentinel_t<R>,
                   (ranges::sized_range<R>||
                   std::sized_sentinel_for<ranges::sentinel_t<R>,
                   ranges::iterator_t<R>>)?

                   ranges::subrange_kind::sized: ranges::subrange_kind::unsized>;
      (3)(since C++20)
      template<ranges::borrowed_range<R>>

      subrange(R&&,/*make-unsigned-like-t*/<ranges::range_difference_t<R>>)->
          subrange<ranges::iterator_t<R>,ranges::sentinel_t<R>,

                   ranges::subrange_kind::sized>;
      (4)(since C++20)

      Thesededuction guides are provided forstd::ranges::subrange.

      1) Deduces the template arguments from the type of iterator and sentinel. Thesubrange is sized ifstd::sized_sentinel_for<S, I> is satisfied, as determined by the default template argument.
      2) Deduces the template arguments from the type of iterator and sentinel, while the size of range is specified. Thesubrange is always sized.
      3) Deduces the template arguments from the type of range. Thesubrange is sized if the size can be obtained from the range or its iterator and sentinel.
      4) Deduces the template arguments from the type of range, while the size of range is specified. Thesubrange is always sized.

      For the definition of/* make-unsigned-like-t */, seemake-unsigned-like-t .

      [edit]Notes

      While constructing thesubrange object,

      • for(1,2), the behavior is undefined if the iterator-sentinel pair does not denote a valid range,
      • for(2,4), the behavior is undefined if the given size is not 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
      LWG 3404C++20meaningless deduction guides from pair-like types were providedremoved
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/subrange/deduction_guides&oldid=176145"

      [8]ページ先頭

      ©2009-2025 Movatter.jp