std::launder
summary
C++17 adds std::launder to allow reusing an old pointer after placement new when the new object has const or reference members by acting as a compiler-optimization barrier rather than mutating pointers. It requires calling launder each time an old pointer is used for the new object and does not make some previously-UB patterns safe (certain aliasing cases remain UB). Empirical note: a study found 40% of placement uses in one codebase ignore placement-new’s returned pointer.
AI-written summary · about
related talks
49mBack to Basics: C++ Smart Pointers
58mTaking a Byte Out of C++ - Avoiding Punning by Starting Lifetimes
01h 00mAn (In-) Complete Guide to C++ Object Lifetimes
35mAn (In-)Complete Guide To C++ Object Lifetimes
01h 02mA Lock-Free Atomic Shared Pointer in Modern Cpp
04m(don't) Copy Paste All The Things
50mTwo advanced PMR techniques in C++17/20
01h 03mTaming dynamic memory
