Writing C++ to Be Read
summary
Argues for concrete practices: prefer the rule of zero and aggregates so the compiler generates constructors/comparisons (use defaulted spaceship) and you write less buggy boilerplate; use designated initializers for clear option structs; replace sentinel values and out-params with std::optional; pass sequences with std::span instead of pointer+size; transfer ownership with unique_ptr, share with shared_ptr; avoid ambiguous bool parameters and prefer named enums; document team naming and parameter conventions for faster onboarding.
AI-written summary · about
chapters (13)
- 0:00Introduction and motivation
- 6:09Code review mindset
- 9:23Avoid clever code
- 15:49Letting compiler write code
- 22:57Aggregates and initialization
- 29:03Returning multiple values
- 32:14Keep it simple
- 34:21Function intent and parameters
- 39:00Invalid values and optionals
- 44:40Booleans and enums
- 46:48Passing arrays with span
- 49:57Smart pointers and ownership
- 51:41Summary and conclusion
related talks
01h 01mEasy to Use, Hard to Misuse: Declarative Style in C++
47mHelp, My Team Is Stuck In The 90s
59mC++ Code Smells
01h 23mThis is C++ - How to Use the C++ Superpower to Write Better C++ Code
01h 01mSome Programming Myths Revisited
01h 33mSafe and Sane C++ Types
01h 22mSimplicity: not just for beginners
01h 04m“Sane and Safe C++ Classes”
