Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++object lifetime and std::launderSingle-choice MCQ

Inside an array of objects, you reuse one element's storage by destroying it and placement-new'ing a new object whose type happens to be the SAME as the element type but which is a transparently replaceable object. Under what condition does the standard let you keep using the array element via the ordinary array subscript (and the array pointer) WITHOUT std::launder?

alignas(T) unsigned char buf[sizeof(T) * N]; T* arr = /* objects created in buf */; arr[k].~T(); T* p = new (&arr[k]) T(...); // same type T