Open
Description
From https://stackoverflow.com/q/66755218
[tab:cpp17.allocator] has the following example added by p0593r6:
When reusing storage denoted by some pointer value
p
,launder(reinterpret_cast<T*>(new (p) byte[n * sizeof(T)]))
can be used to implicitly create a suitable array object and obtain a pointer to it.
If T
is not an implicit-lifetime type, then, even if an object of type T[m ≤ n]
is created, the lifetimes of the array elements are not started, which means launder
's preconditions are violated:
Preconditions:
p
represents the addressA
of a byte in memory. An objectX
that is within its lifetime and whose type is similar toT
is located at the addressA
.