Preconditions: p represents the address A of a byte in memory.
An object X
whose type is similar ([conv.qual]) to T
is located at the address A, and
is either within its lifetime ([basic.life]) or
is an array element subobject
whose containing array object is within its lifetime.
All bytes of storage that would be
reachable through ([basic.compound]) the result
are reachable through p.
Remarks: An invocation of this function
may be used in a core constant expression
if and only if the (converted) value of its argument
may be used in place of the function invocation.
If a new object is created
in storage occupied by an existing object of the same type,
a pointer to the original object
can be used to refer to the new object
unless its complete object is a const object or it is a base class subobject;
in the latter cases,
this function can be used to obtain a usable pointer to the new object.
[Example 1: struct X {int n; };
const X *p =newconst X{3};
constint a = p->n;
new(const_cast<X*>(p))const X{5}; // p does not point to new object ([basic.life]) because its type is constconstint b = p->n; // undefined behaviorconstint c = std::launder(p)->n; // OK — end example]