C++ Logo

std-discussion

Advanced search

Re: Is it valid use reinterpret_cast to form pointer to object?

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Tue, 1 Aug 2023 10:00:25 +0300
On Tue, 1 Aug 2023 at 08:58, Lénárd Szolnoki via Std-Discussion
<std-discussion_at_[hidden]> wrote:
> The need for launder is much more clear regarding compiler optimisations if the same storage is used to hold different objects during its lifetime. But you technically need it when the storage only ever holds a single object.

Well.. in the OP example, the storage first has an array of std::byte
in it, and then has a T in it.

Received on 2023-08-01 07:00:39