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.
Section: 22.5.3.1 [optional.optional.general], 22.6.3.1 [variant.variant.general] Status: C++23 Submitter: Casey Carter Opened: 2022-06-08 Last modified: 2023-11-22
Priority: Not Prioritized
View all other issues in [optional.optional.general].
View all issues with C++23 status.
Discussion:
LWG 3703(i) struck redundant language from 22.8.7.1 [expected.void.general] specifying that
(1) space allocated for an object is suitably aligned, and (2) a member annotated // exposition only
in a class synopsis "is provided for exposition only."
optional
and variant
.
[2022-06-21; Reflector poll]
Set status to Tentatively Ready after nine 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.
Modify 22.5.3.1 [optional.optional.general] as indicated:
-1- Any instance of
-2-optional<T>
at any given time either contains a value or does not contain a value. When an instance ofoptional<T>
contains a value, it means that an object of typeT
, referred to as the optional object's contained value, is allocated within the storage of the optional object. Implementations are not permitted to use additional storage, such as dynamic memory, to allocate its contained value.The contained value shall be allocated in a region of theWhen an object of typeoptional<T>
storage suitably aligned for the typeT
.optional<T>
is contextually converted tobool
, the conversion returnstrue
if the object contains a value; otherwise the conversion returnsfalse
.MemberWhen anval
is provided for exposition only.optional<T>
object contains a value, memberval
points to the contained value.
Modify 22.6.3.1 [variant.variant.general] as indicated:
-1- Any instance of
variant
at any given time either holds a value of one of its alternative types or holds no value. When an instance ofvariant
holds a value of alternative typeT
, it means that a value of typeT
, referred to as thevariant
object's contained value, is allocated within the storage of thevariant
object. Implementations are not permitted to use additional storage, such as dynamic memory, to allocate the contained value.The contained value shall be allocated in a region of the variant storage suitably aligned for all types inTypes
.