Fixing Two-Phase Initialization
summary
Claims a concrete idiom: a preconstruct member function that does all fallible work and returns a construction token carrying the initialized state, then a noexcept constructor consumes the token. Implements this instead of private-create or two-phase init, avoids partially initialized objects in no-exception builds, and it works with make_shared and emplace_back so libraries like containers and smart pointers accept it; implementation is built and demonstrated to work.
AI-written summary · about
chapters (4)
- 0:00The problem with constructors
- 0:42Two-phase initialization
- 1:32Static factory methods
- 2:52Inverse two-phase initialization
related talks
01h 01mInitialization in modern C++
04m(don't) Copy Paste All The Things
11mLightning talk: Manual (de)initialization A Rust and C++
53mThe Static Initialization Order Fiasco
01h 01mC++ Object Lifetime: From Start to Finish
38mInitialization in Rust with pin-init
06mSafe bool idiom
54mPersonal Log - Where No Init Has Gone Before in C++
