The Nightmare of Initialization in C++
summary
Claims that there are 19 ways to initialize an int and shows real breakage: copy vs direct vs brace vs auto+brace produce different types and overload resolution, initializer_list changes make vector{1} differ from vector(1), and compilers (Clang 3.8, GCC 5, MSVC 2015) only gradually adopt fixes. Demonstrates C++14/17/20 fixes (initializer_list rules, prvalue materialization, atomic and aggregate adjustments) and advises auto + {} is dangerous and to prefer braces as the default.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 1:11History of initialization
- 8:08Uniform initialization basics
- 12:51Almost Always Auto rule
- 19:52C++17 improvements
- 24:44Value categories in C++17
- 31:14Most vexing parse
- 34:56Narrowing conversions
- 36:04Initializer lists
- 41:28Enumerations
- 44:20Explicit constructors
- 47:20Aggregates in C++17
- 50:13Arrays vs vectors
- 52:02Atomic initialization
- 53:32Assert macros
- 54:17Style guide recommendations
- 58:17Call to action
related talks
54mWriting C++ to Be Read
32mCute C++ Tricks, Part 2 of N: More code you should learn from and never write
01h 01mSome Programming Myths Revisited
54mC++ Common Knowledge
01h 21mEmpirically Measuring, & Reducing, C++’s Accidental Complexity
57m“The Nightmare of Move Semantics for Trivial Classes”
01h 34mC++11/14 at Scale - What Have We Learned?
01h 31mThe C++ Vector Challenge
