Date: Thu, 9 Sep 2021 00:58:27 -0400
On Wed, Sep 8, 2021 at 2:29 PM D'Alessandro, Luke K via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
>
> I guess I have two questions:
>
> 1. Does std::construct_at change the active member of a union?
As stated in [class.union]/2, "a non-static data member is active if
its name refers to an object whose lifetime has begun and has not
ended." `construct_at` can begin the lifetime of objects (which can
also cause the lifetime of other overlapping objects to end).
Therefore, it can change the active union member.
> 2. If 1, can std::construct_at benefit from the logic in https://eel.is/c++draft/class.union#general-6 that begins the lifetime of a nominated member?
No. That paragraph applies to the explicit use of the assignment operator.
<std-proposals_at_[hidden]> wrote:
>
>
> I guess I have two questions:
>
> 1. Does std::construct_at change the active member of a union?
As stated in [class.union]/2, "a non-static data member is active if
its name refers to an object whose lifetime has begun and has not
ended." `construct_at` can begin the lifetime of objects (which can
also cause the lifetime of other overlapping objects to end).
Therefore, it can change the active union member.
> 2. If 1, can std::construct_at benefit from the logic in https://eel.is/c++draft/class.union#general-6 that begins the lifetime of a nominated member?
No. That paragraph applies to the explicit use of the assignment operator.
Received on 2021-09-08 23:59:16