“Sane and Safe C++ Classes”
summary
Categorizes C++ types into value, empty, managing, pointing and polymorphic classes and gives concrete rules for special member functions and ownership patterns so you avoid undefined behavior. Explains Rule of Zero versus explicit Rule of Five/Six and recommends deleting move assignment when you declare a destructor to prevent slicing. Demonstrates surprising failures like NaN in std::set yields size 1 and unsigned loop wrap creating infinite loops, and points to no_unique_address to shrink empty-member objects.
AI-written summary · about
chapters (16)
- 0:00Start
- 5:34Plane Pointers
- 16:09Signed and Unsigned Arithmetic
- 19:20The Whole Value Pattern
- 20:48Value Types
- 30:42How Does Empty Base Class Optimization Work in C
- 35:31Empty Adapters
- 40:30Pointers in Disguise Are Iterators
- 43:20Smart Pointers
- 44:15Shared Pointer
- 44:46String View
- 49:54Monomorphic Object Types
- 50:56The Manager Design Pattern
- 54:21Combinations of Special Member Functions
- 57:29Model with Value Types
- 59:09Pointing Types
related talks
57mSane and Safe C++ Class Types
01h 20mWhat Classes We Design and How
01h 33mSafe and Sane C++ Types
01h 01mC++ Class Natures in Their Canonical Form and How to Find Them
54mWriting C++ to Be Read
55m“Using Types Effectively"
01h 23mThis is C++ - How to Use the C++ Superpower to Write Better C++ Code
56mIdentifying Common Code Smells
