This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

3615. The last specialization of incrementable_traits has wrong operand types

Section: [incrementable.traits] Status: New Submitter: Hewill Kang Opened: 2021-09-30 Last modified: 2022-01-31

Priority: 3

View all issues with New status.


The last specialization of incrementable_traits requires a - b to be well-formed, where the types of both operands are const lvalue reference of type T. However inside the struct, it uses decltype(declval<T>() - declval<T>()) to define the difference_type, that is, non-const rvalue reference of type T.

[2022-01-29; Reflector poll]

Set priority to 3 after reflector poll that failed to reach consensus. Some suggested NAD: "Implicit expression variations ([concepts.equality]/6) apply here."

Proposed resolution:

This wording is relative to N4892.

  1. Modify [incrementable.traits] as indicated:

    namespace std {
      template<class T>
        requires (!requires { typename T::difference_type; } &&
                  requires(const T& a, const T& b) { { a - b } -> integral; })
      struct incrementable_traits<T> {
        using difference_type = make_signed_t<decltype(declval<const T&>() - declval<const T&>())>;