incrementable_traits
has wrong operand typesSection: 24.3.2.1 [incrementable.traits] Status: New Submitter: Hewill Kang Opened: 2021-09-30 Last modified: 2022-01-31
Priority: 3
View other active issues in [incrementable.traits].
View all other issues in [incrementable.traits].
View all issues with New status.
Discussion:
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.
Modify 24.3.2.1 [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&>())>; }; […] }