Improving Our Safety With a Modern C++ Quantities and Units Library
summary
Shows a concrete library: mp‑units implements P2981 to enforce compile‑time physical quantity and unit safety with C++20 (optional C++23) features, no runtime/size overhead, and readable compiler diagnostics. Demonstrates preventing real bugs (Mars Climate Orbiter pounds vs kilograms, Air Canada fuel misunits, Vasa ship rulers) and models quantity kinds, quantity points, vectors/tensors, and safe conversions; reproduces Columbus’s unit miscommunication (≈31% then refined to ≈24% error). Library builds on GCC/Clang today, fails to compile on current MSVC, and is under consideration for C++29 standardization.
AI-written summary · about
chapters (8)
- 0:00Safety with quantities and units
- 13:55Unit-related disasters
- 20:02MP-units library for C++
- 33:33Unit-safe abstractions
- 46:57Columbus navigation errors
- 59:47Quantity kinds and type safety
- 1:18:08Library pitfalls and limits
- 1:29:59Summary and future
related talks
01h 02mA Physical Units Library For C++
01h 05mA C++ Approach to Physical Units
01h 09m“Boost Units Library for Correct Code"
58mSoftware Engineering Is About Tradeoffs
01h 01mRethinking the Way We Do Templates in C++
33mThe IT Path to Universal Measurement
58mSimplify and Secure Equation Systems with Type-Driven Development
26mDon't Package Your Libraries, Write Packagable Libraries! (Part 2)
