How do placement construction, alignment, explicit destruction, transparent replacement, and storage reuse interact with C++ object lifetime?
Show answer and explanation
A non-allocating placement new-expression, or std::construct_at in C++20, creates an object in storage supplied by the caller; it does not acquire that storage. The region must be large enough, correctly aligned, writable, and alive for the operation. Construction starts the new object's lifetime after initialization completes and can end the lifetime of an object whose storage is reused. Destroy a live non-trivial object when its cleanup is required, and use std::destroy_at for symmetry; destruction does not deallocate the backing storage. Old names, pointers, and references automatically designate a replacement only under the transparent-replacement rules. Otherwise use the pointer returned by construction and std::launder only where its preconditions apply. Never reuse storage occupied by a complete const object, and prefer optional, variant, containers, or allocators when they can manage these invariants.
A non-allocating placement new-expression, or std::construct_at in C++20, creates an object in storage supplied by the caller; it does not acquire that storage. The region must be large enough, correctly aligned, writable, and alive for the operation. Construction starts the new object's lifetime after initialization completes and can end the lifetime of an object whose storage is reused. Destroy a live non-trivial object when its cleanup is required, and use std::destroy_at for symmetry; destruction does not deallocate the backing storage. Old names, pointers, and references automatically designate a replacement only under the transparent-replacement rules. Otherwise use the pointer returned by construction and std::launder only where its preconditions apply. Never reuse storage occupied by a complete const object, and prefer optional, variant, containers, or allocators when they can manage these invariants.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.