Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::sized_sentinel_for,std::disable_sized_sentinel_for

      From cppreference.com
      <cpp‎ |iterator
       
       
      Iterator library
      Iterator concepts
      sized_sentinel_for
      (C++20)

      Iterator primitives
      Algorithm concepts and utilities
      Indirect callable concepts
      Common algorithm requirements
      (C++20)
      (C++20)
      (C++20)
      Utilities
      (C++20)
      Iterator adaptors
      Range access
      (C++11)(C++14)
      (C++14)(C++14)  
      (C++11)(C++14)
      (C++14)(C++14)  
      (C++17)(C++20)
      (C++17)
      (C++17)
       
      Defined in header<iterator>
      template<class S,class I>

          concept sized_sentinel_for=
             std::sentinel_for<S, I>&&
             !std::disable_sized_sentinel_for<std::remove_cv_t<S>,
                                               std::remove_cv_t<I>>&&
              requires(const I& i,const S& s){
                 { s- i}->std::same_as<std::iter_difference_t<I>>;
                 { i- s}->std::same_as<std::iter_difference_t<I>>;

             };
      (1)(since C++20)
      template<class S,class I>
         inlineconstexprbool disable_sized_sentinel_for=false;
      (2)(since C++20)
      1) Thesized_sentinel_for concept specifies that an object of the iterator typeI and an object of the sentinel typeS can be subtracted to compute the distance between them in constant time.
      2) Thedisable_sized_sentinel_for variable template can be used to prevent iterators and sentinels that can be subtracted but do not actually modelsized_sentinel_for from satisfying the concept.
      A program may specializedisable_sized_sentinel_for for cv-unqualified non-array object typeS andI, as long as at least one of which is aprogram-defined type. Such specializations are usable inconstant expressions and have typeconstbool.

      Contents

      [edit]Semantic requirements

      Leti be an iterator of typeI, ands a sentinel of typeS such that[is) denotes a range. Letn be the smallest number of applications of++i necessary to makebool(i== s) betrue.I andS modelsized_sentinel_for<S, I> only if all following conditions are satisfied:

      [edit]Equality preservation

      Expressions declared inrequires expressions of the standard library concepts are required to beequality-preserving (except where stated otherwise).

      [edit]Implicit expression variations

      Arequires expression that uses an expression that is non-modifying for some constant lvalue operand also requiresimplicit expression variations.

      [edit]See also

      specifies that a range knows its size in constant time
      (concept)[edit]
      returns an integer equal to the size of a range
      (customization point object)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/iterator/sized_sentinel_for&oldid=170161"

      [8]ページ先頭

      ©2009-2025 Movatter.jp