9 Iterators library [iterators]

9.3 Iterator requirements [iterator.requirements]

9.3.6 Concept WeaklyIncrementable [iterators.weaklyincrementable]

The WeaklyIncrementable concept specifies the requirements on types that can be incremented with the pre- and post-increment operators. The increment operations are not required to be equality-preserving, nor is the type required to be EqualityComparable.

  template <class I>
  concept bool WeaklyIncrementable =
    Semiregular<I> &&
    requires(I i) {
      typename difference_type_t<I>;
      requires SignedIntegral<difference_type_t<I>>;
      { ++i } -> Same<I>&; // not required to be equality preserving
      i++; // not required to be equality preserving
    };

Let i be an object of type I. When i is in the domain of both pre- and post-increment, i is said to be incrementable. WeaklyIncrementable<I> is satisfied only if

  • The expressions ++i and i++ have the same domain.

  • If i is incrementable, then both ++i and i++ advance i to the next element.

  • If i is incrementable, then &++i is equal to &i.

Note: For WeaklyIncrementable types, a equals b does not imply that ++a equals ++b. (Equality does not guarantee the substitution property or referential transparency.) Algorithms on weakly incrementable types should never attempt to pass through the same incrementable value twice. They should be single pass algorithms. These algorithms can be used with istreams as the source of the input data through the istream_iterator class template. — end note ]