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 2 weeks ago

Messages

Date: 2021-10-03.17:55:36

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: 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
2021-10-03 17:55:36adminsetmessages: + msg12101
2021-09-30 00:00:00admincreate