Safe and Sane C++ Types
summary
Argues that raw pointers and C-style arrays are obsolete: use unique_ptr and RAII to eliminate leaks and double-free, with code shown on GitHub for a unique_resource helper (works but needs cross-compiler fixes). Demonstrates concrete bugs: NaN collapses a std::set to size 1, unsigned size()-1 makes an infinite loop, and string_view easily dangles. Recommends strong primitive wrappers to prevent swapped-argument bugs, using empty-type mixins and empty-base optimization to keep wrappers zero-overhead, and applies the Rule of Desdemona (delete move-assignment when defining a destructor).
AI-written summary · about
chapters (37)
- 0:00Introduction and audience
- 1:09Modern C++ safety improvements
- 3:49Safety critical systems and regulation
- 7:01Value types in C++
- 8:48Empty types and their uses
- 9:33Deterministic lifetime model
- 10:17Avoiding dynamic polymorphism
- 11:01Potentially dangling types
- 12:46Regular and semi-regular types
- 15:22C++20 and future changes
- 16:28Rule of Des to mover
- 17:11Type categories and usage
- 19:23Primitive types safety issues
- 23:29Double type pitfalls
- 28:38Built-in type problems
- 34:24Primitive type wrappers
- 37:20Strong typing and domain modeling
- 43:55Wrapping value types
- 46:23Assign spaces and unit types
- 49:56Empty classes and their uses
- 53:35Compile-time computation with empty types
- 56:00Empty base class optimization
- 1:00:21Unique pointers and memory management
- 1:02:07Adaptors and inheriting constructors
- 1:03:34Potentially dangling object types
- 1:07:14Iterators and dangling references
- 1:11:05Pointer alternatives and guidelines
- 1:13:15Smart pointers and heap allocation
- 1:14:41Views and spans
- 1:17:17Discipline with pointer types
- 1:18:19Managing and pointing types
- 1:22:16Unique resource implementation
- 1:23:02Dynamic polymorphism pitfalls
- 1:25:19Rule of Des to mover recap
- 1:26:50Type erasure and value semantics
- 1:28:15Aggregate and value classes
- 1:30:43Key takeaways and conclusion








