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 12:36:32 +0300
On Tue, Aug 1, 2023, 12:30 Bjorn Reese via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> On 8/1/23 02:21, Ville Voutilainen via Std-Discussion wrote:
>
> > That should also have nothing to do with start_lifetime_as, because
> > that placement-new plus the later address-obtaining and use
> > should work even for non trivial types, for any T, regardless of
> > whether trivial or complex, so start_lifetime_as doesn't solve
> > any problems here anyway.
>
> Notice that the OP is asking about the case where placement-new is
> omitted.


Where? All the OP is asking is using a reinterpret_cast of the original
array's address instead of using the result of placement new.

Received on 2023-08-01 09:36:46