C++ Logo

std-proposals

Advanced search

Re: [std-proposals] An issue with IOC

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sun, 2 Oct 2022 11:22:17 -0400
On Sun, Oct 2, 2022 at 10:37 AM blacktea hamburger via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> However, the implicitly created object does end the lifetime of the original char objects. Although it can be accessed by char, the result of the access is no longer the original char objects' value (it's also not accessed by char).
>
> No copies are made in the code, which requires std::bit_cast or std::start_lifetime_as, which makes a change instead of a copy.

Oh, and it's important to remember [intro.object]/3: When you create
an object in a byte array (though it requires `unsigned char` or
`std::byte`, so the P0593 example used the wrong type), that byte
array still exists. This means that it "provides storage" for the
object, so the object is "nested within" the byte array. And per
[intro.object]/1.5, the lifetime of the outer object only ends when
creating an overlapping object if the overlapping object is not
"nested within" the outer object.

Received on 2022-10-02 15:23:33