The Power of C++ Templates With mp-units: Lessons Learned & a New Library Design
summary
mp-units v2 rewrites the library: removes the problematic Downcasting Facility, abandons user-defined literals for quantities, and models ISO ISQ quantity trees so frequency, radioactivity and “one per second” stay distinct. It uses heavy C++20/23 NTTPs and expression templates to generate readable compiler types, supports quantity kinds for safe addition/conversion (preventing Hz+Bq), exposes value/reference as structural NTTPs, and requires modern compilers (GCC 12.2+) while adding features like compile‑time physical constants (g, c) that strip where possible.
AI-written summary · about
chapters (15)
- 0:00mp-units library rewrite intro
- 1:46Previous design issues
- 8:27Doncaster casting limits
- 17:14User-defined literals drawbacks
- 21:50mp-units v2 introduction
- 25:23International System of Quantities
- 31:01Quantity kinds importance
- 39:38Quantity specs & units
- 48:51Creating quantities in v2
- 54:08Error messages with expression templates
- 1:00:27Quantity conversions & casts
- 1:08:59ADL limits with NTTPs
- 1:14:09Affine types & quantity points
- 1:16:12Lightweight physical constants
- 1:19:45Improvements & future directions
related talks
01h 02mA Physical Units Library For C++
01h 08mA Physical Units Library For the Next C++
01h 37mRethinking the Way We Do Templates in C++ even more
01h 30mEnhancing Safety in C++ Code With Modern C++ Quantities and Units Library
01h 31mImplementing Physical Units Library for C++
01h 03mHow to Improve the Safety of C++ Code With a Quantities & Units Library
01h 30mRethinking the Way We Do Templates in C++
01h 13mThe 10 Essential Features for the Future of C++ Libraries
