C++ Logo


Advanced search

Subject: Re: Implicit object creation, arrays, and non-implicit lifetime objects
From: Jason McKesson (jmckesson_at_[hidden])
Date: 2021-03-25 22:09:31

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

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

Older Archives on Google Groups