3709. LWG-3703 was underly ambitious

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 other active issues in [optional.optional.general].

View all other issues in [optional.optional.general].

View all issues with C++23 status.

Discussion:

LWG 3703 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."

Let's also strike similar occurrences from the wording for 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.

  1. Modify 22.5.3.1 [optional.optional.general] as indicated:

    -1- Any instance of optional<T> at any given time either contains a value or does not contain a value. When an instance of optional<T> contains a value, it means that an object of type T, 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 the optional<T> storage suitably aligned for the type T. When an object of type optional<T> is contextually converted to bool, the conversion returns true if the object contains a value; otherwise the conversion returns false.

    -2- Member val is provided for exposition only. When an optional<T> object contains a value, member val points to the contained value.

  2. 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 of variant holds a value of alternative type T, it means that a value of type T, referred to as the variant object's contained value, is allocated within the storage of the variant 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 in Types.