“Safe Numerics”
summary
Boost.SafeNumerics uses operator overloading and template metaprogramming to make integers that either trap at compile time or throw at runtime, with configurable promotion policy (native, cpp, automatic) and an optional trap policy that forces compile-time failures. Applied to a PIC-based stepper motor controller, the 179-line implementation compiles to ~1,300 bytes on a 32K device, finds a real overflow at ~500 mm, reduces runtime checks to seven sites, and enables zero-overhead correctness by widening only the temporaries and using range-checked literals and Boost.SafeNumerics types.
AI-written summary · about
chapters (11)
- 0:00The problem with integers
- 2:58Introducing safe numerics
- 5:58Runtime check elimination
- 8:53Real-world embedded case study
- 13:27Algorithm implementation
- 17:56Testing on the desktop
- 25:32Promotion and trap policies
- 32:36Compile-time range arithmetic
- 43:46Refactoring for verification
- 50:20Minimizing runtime costs
- 55:26Q&A session
related talks
21mSafe Numerics Library
42mfixed_point
57mSane and Safe C++ Class Types
01h 31mWhat C++ Needs to be Safe
01h 28mEmbracing the **noexcept** Operator and Specifier *Safely*
44mFastware
01h 09mOverengineering max(a, b) Mixed Comparison Functions, Common References & Rust Lifetime Annotations
01h 23mThis is C++ - How to Use the C++ Superpower to Write Better C++ Code
