This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.
bool
can't be an integer-like typeSection: 24.3.4.4 [iterator.concept.winc] Status: C++23 Submitter: Casey Carter Opened: 2020-07-23 Last modified: 2023-11-22
Priority: 0
View all other issues in [iterator.concept.winc].
View all issues with C++23 status.
Discussion:
Per 25.2 [ranges.syn]/1, the Standard Library believes it can convert an integer-like type X
to an unsigned integer-like type with the exposition-only type alias make-unsigned-like-t
.
make-unsigned-like-t<X>
is specified as being equivalent to
make_unsigned_t<X>
when X
is an integral type. However, despite being an integral type,
bool
is not a valid template type argument for make_unsigned_t
per [tab:meta.trans.sign].
bool
was an oversight when we added support for integer-like types: it was certainly
not the design intent to allow ranges::size(r)
to return false
! While we could devise some
more-complicated metaprogramming to allow use of bool
, it seems easier — and consistent with the
design intent — to simply exclude bool
from the set of integer-like types.
[2020-08-02; Reflector prioritization]
Set priority to 0 and status to Tentatively Ready after six votes in favour during reflector discussions.
[2020-11-09 Approved In November virtual meeting. Status changed: Tentatively Ready → WP.]
Proposed resolution:
This wording is relative to N4861.
Modify 24.3.4.4 [iterator.concept.winc] as indicated:
-11- A type
I
other thancv bool
is integer-like if it modelsintegral<I>
or if it is an integer-class type. An integer-like typeI
is signed-integer-like if it modelssigned_integral<I>
or if it is a signed-integer-class type. An integer-like typeI
is unsigned-integer-like if it modelsunsigned_integral<I>
or if it is an unsigned-integer-class type.