Type safe C++? LOL!
summary
Argues C++ can be made reliably type safe by turning primitives into distinct types using a safe_type<T,Tag> template with deleted cross-constructors and the CRTP tag trick so requestID and receiverID cannot mix. Demonstrates serializing slot counts as a dedicated type, models indices/counts as affine-space relations, and warns of the enum class fruit salad bug that breaks presumed safety. Shows small custom library plus GitHub strong-type/name-type implementations, and measures no runtime cost — sometimes slight speedups.
AI-written summary · about
chapters (11)
- 0:00Start
- 1:29What Is Type Safety
- 7:37Compilation Error
- 18:57Type Safe Library Zero Overhead Utilities for Preventing Bugs at Compile Time
- 25:50What Happens with Your Code When You Use Strong Types
- 29:48Encapsulation
- 32:30Type Semantics
- 37:26Affine Space Types
- 38:53Test Code
- 45:52Type Aliases
- 46:37Aliasing








