Building Cpp Interfaces That Are Hard to Use Incorrectly
summary
C++ interfaces become harder to misuse by encoding preconditions in types: replace loose GLenum/ints with enum class handles or small wrapper structs (tagged strong types), use structs or designated initializers instead of ambiguous argument lists, enforce limited access with the passkey idiom, and model allowed state transitions by consuming and returning distinct types or cheap execution tokens; examples include GL/Vulkan command-recording and iterator/container invalidation, and tools like clang-tidy catch use-after-move or dead-state uses.
AI-written summary · about
chapters (14)
- 0:00Introduction and motivation
- 1:50Precondition violations explained
- 4:38Invalid arguments vs invalid context
- 21:57Type system as a prevention tool
- 23:42Strong types for OpenGL
- 29:16Opaque type definitions
- 32:31Structured arguments and data
- 35:41Handling variants safely
- 38:54Limited friendship with passkey
- 41:43Declarative interfaces
- 44:29Modeling state through types
- 47:01Execution tokens
- 50:54State modeling in Vulkan
- 54:26Trade-offs and conclusion
related talks
01h 36mBuilding C++ Interfaces That Are Hard to Use Incorrectly
58mHow to Build Cpp Interfaces That Are Hard to Use Incorrectly
54mTypical C++, But Why?
51mTypical C++, but Why?
01h 01mEasy to Use, Hard to Misuse: Declarative Style in C++
41m“Avoiding Disasters with Strongly Typed C++”
01h 20mWhat Classes We Design and How
51mThe C++ Type System is your Friend
