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.
expected<T, E> requires is_void<T>
Section: 22.8.7.1 [expected.void.general] Status: C++23 Submitter: Casey Carter Opened: 2022-05-24 Last modified: 2023-11-22
Priority: 2
View all issues with C++23 status.
Discussion:
The partial specialization expected<T, E> requires is_void<T>
specified in
22.8.7.1 [expected.void.general] is missing some template parameter requirements that should
have been copied from 22.8.6.1 [expected.object.general]. We should copy the pertinent
requirements from the first two paragraphs of the latter subclause into new paragraphs in the first
subclause (the pertinent requirement from the third paragraph is already present in
22.8.7.1 [expected.void.general]).
[2022-06-21; Jonathan adds "Member" before "has_val
"]
[2022-06-21; Reflector poll]
Set priority to 2 after reflector poll.
[2022-06-21; Reflector poll]
Set status to Tentatively Ready after five votes in favour during reflector poll.
[2022-07-15; LWG telecon: move to Ready]
[2022-07-25 Approved at July 2022 virtual plenary. Status changed: Ready → WP.]
Proposed resolution:
This wording is relative to N4910.
[Drafting note: There is some drive-by cleanup that I couldn't resist while touching this wording: (1) strike the redundant "suitably aligned" guarantee, (2) Don't repeat in prose that the exposition-only members are exposition-only.]
Modify 22.8.6.1 [expected.object.general] as indicated:
-1- Any object of type
expected<T, E>
either contains a value of typeT
or a value of typeE
within its own storage. Implementations are not permitted to use additional storage, such as dynamic memory, to allocate the object of typeT
or the object of typeE
.These objects are allocated in a region of theMemberexpected<T, E>
storage suitably aligned for the typesT
andE
. Membershas_val
,val
, andunex
are provided for exposition only.has_val
indicates whether theexpected<T, E>
object contains an object of typeT
.
Modify 22.8.7.1 [expected.void.general] as indicated:
-?- Any object of type
-?- A program that instantiates the definition of the templateexpected<T, E>
either represents a value of typeT
, or contains a value of typeE
within its own storage. Implementations are not permitted to use additional storage, such as dynamic memory, to allocate the object of typeE
. Memberhas_val
indicates whether theexpected<T, E>
object represents a value of typeT
.expected<T, E>
with a type for theE
parameter that is not a valid template argument forunexpected
is ill-formed. -1-E
shall meet the requirements of Cpp17Destructible (Table [tab:cpp17.destructible]).