Scroll to navigation

std::weakly_incrementable(3) C++ Standard Libary std::weakly_incrementable(3)

NAME

std::weakly_incrementable - std::weakly_incrementable

Synopsis


Defined in header <iterator>
template< class I >


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


};


where /*is-signed-integer-like*/<I> is true if and only if I is a
signed-integer-like type (see below).


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


For std::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 through
std::istream_iterator.

See also


incrementable specifies that the increment operation on a weakly_incrementable type
(C++20) is equality-preserving and that the type is equality_comparable
(concept)

2024.06.10 http://cppreference.com