Title
The last specialization of incrementable_traits has wrong operand types
Status
new
Section
[incrementable.traits]
Submitter
Hewill Kang

Created on 2021-09-30.00:00:00 last changed 35 months ago

Messages

Date: 2022-01-29.22:17:14

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&>())>;
      };
      […]
    }
    
Date: 2022-01-15.00:00:00

[ 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."

Date: 2021-09-30.00:00:00

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.

History
Date User Action Args
2022-01-29 22:17:14adminsetmessages: + msg12284
2021-10-03 17:55:36adminsetmessages: + msg12101
2021-09-30 00:00:00admincreate