Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::sentinel_for

      From cppreference.com
      <cpp‎ |iterator
       
       
      Iterator library
      Iterator concepts
      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 sentinel_for=
             std::semiregular<S>&&
             std::input_or_output_iterator<I>&&

              __WeaklyEqualityComparableWith<S, I>;
      (since C++20)

      Thesentinel_for concept specifies the relationship between aninput_or_output_iterator type and asemiregular type whose values denote a range. The exposition-only concept__WeaklyEqualityComparableWith is described inequality_comparable.

      [edit]Semantic requirements

      Lets andi be values of typeS andI, respectively, such that[is) denotes arange.sentinel_for<S, I> is modeled only if:

      • i== s is well-defined.
      • Ifbool(i!= s) theni is dereferenceable and[++is) denotes a range.
      • std::assignable_from<I&, S> is either modeled or not satisfied.

      The domain of== can change over time. Given an iteratori and sentinels such that[is) denotes a range andi!= s,[is) is not required to continue to denote a range after incrementing any iterator equal toi (and soi== s is no longer required to be well-defined after such an increment).

      [edit]Notes

      A sentinel type and its corresponding iterator type are not required to modelequality_comparable_with, because the sentinel type may not be comparable with itself, and they are not required to have a common reference type.

      It has been permitted to use a sentinel type different from the iterator type in therange-basedfor loop since C++17.

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      LWG 3453C++20semantic requirements forsentinel_for were too loose forranges::advancestrengthened
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/iterator/sentinel_for&oldid=171688"

      [8]ページ先頭

      ©2009-2025 Movatter.jp