Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::weakly_incrementable

      From cppreference.com
      <cpp‎ |iterator
       
       
      Iterator library
      Iterator concepts
      weakly_incrementable
      (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 I>

          concept weakly_incrementable=
             std::movable<I>&&
              requires(I i){
                 typenamestd::iter_difference_t<I>;
                  requires/*is-signed-integer-like*/<std::iter_difference_t<I>>;
                 {++i}->std::same_as<I&>;// not required to be equality-preserving
                  i++;                        // not required to be equality-preserving

             };
      (since C++20)

      For the definition of/*is-signed-integer-like*/, seeis-integer-like .

      This concept specifies requirements on types that can be incremented with the pre- and post-increment operators, but those increment operations are not necessarilyequality-preserving, and the type itself is not required to bestd::equality_comparable.

      Forstd::weakly_incrementable types,a== b does not imply that++a==++b. Algorithms on weakly incrementable types must be single-pass algorithms. These algorithms can be used with istreams as the source of the input data throughstd::istream_iterator.

      [edit]Semantic requirements

      For an objecti of typeI,I modelsstd::weakly_incrementable only if all following conditions are satisfied:

      • The expressions++i andi++ have the same domain.
      • Ifi is incrementable, then both++i andi++ advancei.
      • Ifi is incrementable, thenstd::addressof(++i)==std::addressof(i).

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      P2325R3C++20default_initializable was requirednot required

      [edit]See also

      specifies that the increment operation on aweakly_incrementable type isequality-preserving and that the type isequality_comparable
      (concept)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/iterator/weakly_incrementable&oldid=175986"

      [8]ページ先頭

      ©2009-2025 Movatter.jp