How to Build Cpp Interfaces That Are Hard to Use Incorrectly
summary
Argues that the C++ type system, not wider contracts, prevents common bugs by moving precondition checks to compile time and shows concrete fixes: replacing raw ints for OpenGL glTexImage2D with enum class opaque handles, wrapping handles in a templated struct, using std::span and designated initializers to avoid memset/argument-order errors, switching variants to visit+overload trick, applying execution tokens and “state-as-types” for Vulkan-like command buffers, and using clang‑tidy move checks; demos compile-time gains, added type boilerplate, and runtime trade-offs.
AI-written summary · about
chapters (12)
- 0:00Intro
- 0:45Motivation
- 4:01Overview
- 19:27Type System to the rescue!
- 27:30Structuring arguments
- 31:02Structured Data Access
- 37:11Declarative Interface
- 47:54Execution Tokens
- 49:38Scoped Execution Contexts
- 52:42Complex State Machines
- 55:14The GoF State Pattern
- 56:44Conclusion
related talks
59mBuilding Cpp Interfaces That Are Hard to Use Incorrectly
01h 36mBuilding C++ Interfaces That Are Hard to Use Incorrectly
54mTypical C++, But Why?
51mThe C++ Type System is your Friend
01h 13mType safe C++ – LOL! :-)
01h 10mThe C++ Type System Is Your Friend
57mThe Real Problem of C++
01h 02mOn the benefits of non-intrusiveness
