std::weakly_incrementable(3)

πŸ“¦
version 2024.07.05 Β· 3 versions
, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

std::weakly_incrementable β€” std::weakly_incrementable

Okay bestie, this is the C++ Standard Libary manual page for std::weakly_incrementable, and it's giving concept requirements energy. No cap.


✨ Synopsis ✨

Defined in header <iterator>:

template< class I >
concept weakly_incrementable =
    std::movable<I> &&
    requires(I i) {
        typename std::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
    };

This concept is since C++20, literally.

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).

That's the whole vibe. Source/version: cppreference.com, dated 2024.06.10. Bye bestie πŸ’–βœ¨

πŸ“¦ where this page comes from