The C++ Type System is your Friend
summary
Shows concrete techniques: wrap ints into strong types with user-defined literals and explicit constructors, enforce ranges with constexpr so some errors become compiler errors, and generate operators via templates and CRTP to get relational operations inlined. Builds a compile-time physical-units system (meters/seconds) that prevents mixing units — cites the Mars Climate Orbiter mismatch — and a fixed-length string with pluggable overflow policies using enable_if and SFINAE. Claims zero runtime overhead and demonstrates it compiles down to the same code as raw numbers.
AI-written summary · about
chapters (29)
- 0:00Intro
- 0:30Why this talk
- 1:03Three important things
- 2:50History of programming types
- 5:17Types in C
- 6:46Using the Type System
- 7:55Compilation
- 9:16Example
- 12:42Whole Value Pattern
- 14:35Templates
- 15:35Header Files
- 16:07Constructors
- 18:41Explicit Operations
- 22:18CRTP
- 24:23C Runtime Polymorphism
- 26:25Physical Quantities
- 29:32Related Flavors
- 30:08Template Metaprogramming
- 32:17Operator Traits
- 36:11Fixed Length String
- 37:31Policy Decisions
- 40:18Context Per
- 41:18Runtime Check
- 42:19Implicit vs Explicit
- 44:27Compilation vs Templates
- 46:30First attempt
- 48:05Error messages without concepts
- 48:37Error messages with concepts
- 49:33Summary
related talks
01h 10mThe C++ Type System Is Your Friend
58mHow to Build Cpp Interfaces That Are Hard to Use Incorrectly
01h 13mType safe C++ – LOL! :-)
54mTypical C++, But Why?
01h 30mRethinking the Way We Do Templates in C++
01h 36mBuilding C++ Interfaces That Are Hard to Use Incorrectly
01h 34mMetaprogramming in C++14
57mProgramming for Warm Days: Avoiding Dangerous Conversions
