Initialization in modern C++
summary
Survey of every initializer from C to C++20: precise rules, surprising pitfalls and fixes. Shows when code does value initialization vs zero initialization, how list initialization greedily prefers std::initializer_list and breaks templates and macros, and how C++17 adds guaranteed copy elision while C++20 plans designated fields and paren-based aggregate init. Recommends concrete style rules: use equals for builtins, braces for aggregates and initializer_list, and parens for constructors (or be consistent). Includes a printable table of syntaxes and outcomes.
AI-written summary · about
chapters (12)
- 0:00Intro
- 3:07Default initialisation
- 5:26Copy initialisation
- 11:44Direct initialisation
- 18:20Value initialisation
- 24:10Uniform initialisation
- 33:18List initialisation
- 37:27List init nested braces
- 43:58Guaranteed copy elision
- 47:35Designated initialisation
- 52:31Aggregate initialisation from parens
- 54:13Recommendations
related talks
59mC++20: the small things
52mExploring C++17 and beyond
01h 10mAn Overview of C++11/14, Part II
01h 00mC++20 - the hidden pearls
01h 02mBack to Basics: const and constexpr
01h 03mBack to Basics: The C++ Core Guidelines
01h 40mBack to the Basics! Essentials of Modern C++ Style
11mLightning talk: Manual (de)initialization A Rust and C++
