C++ Logo


Advanced search

Subject: Re: Implicit object creation, arrays, and non-implicit lifetime objects
From: language.lawyer_at_[hidden]
Date: 2021-03-25 22:45:25


On 26/03/2021 06:09, Jason McKesson via Std-Discussion wrote:
> Indeed, I found an interesting problem here. In the allocator
> requirements `a.allocate`, the standard says that the following code
> can be used to create an array of `T` within the storage `p` without
> necessarily creating `T`s, as well as retrieving a pointer to the
> first `T`:
> ```
> launder(reinterpret_cast<T*>(new (p) byte[n * sizeof(T)]))
> ```
> But we know that doesn't work because `launder` *requires* that there
> must be a `T` *within its lifetime* in that memory. And if `T` is not
> an ILT, then (according to that notation), it shouldn't be within its
> lifetime.

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups