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.
Section: 25.3.2.1 [incrementable.traits] Status: New Submitter: Hewill Kang Opened: 2022-12-07 Last modified: 2023-01-06
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 incremental_traits requires that the result obtained by subtracting two objects of type const T must model integral, then apply make_signed_t to it as the difference type of type T.
However, since bool also models integral, but is not a valid template argument for make_signed_t, we should ban such cases to avoid unnecessary hard errors (online example):
#include <ranges>
struct Bool {
bool operator-(Bool) const;
};
template<class T>
concept can_iota_view = requires(T t) { std::ranges::iota_view(t); };
static_assert(!can_iota_view<Bool>); // hard error
[2022-12-13; Minor wording improvements after LWG reflector discussion]
Remove remove_cv_t within nonbool-integral, because bool prvalues cannot be cv-qualified.
[2023-01-06; Reflector poll]
Set priority to 3 after reflector poll.
"I would prefer to place the new checks directly in the requires-clause instead of introducing nonbool-integral."
Proposed resolution:
This wording is relative to N4917.
Modify 25.3.2.1 [incrementable.traits] as indicated:
namespace std { template<class T> concept nonbool-integral = integral<T> && !same_as<T, bool>; // exposition only template<class T> struct incrementable_traits { }; […] template<class T> requires (!requires { typename T::difference_type; } && requires(const T& a, const T& b) { { a - b } -> nonbool-integralintegral; }) struct incrementable_traits<T> { using difference_type = make_signed_t<decltype(declval<T>() - declval<T>())>; }; […] }