Overengineering max(a, b) Mixed Comparison Functions, Common References & Rust Lifetime Annotations
summary
Implements a fully generic max/min/clamp that handles mixed-type comparisons, fixes unsafe int/unsigned behavior with a TC_common_type that rejects unsafe conversions, and avoids dangling rvalue references by introducing a TC_temporary marker plus macros for forwarding, invoke and lifetime counting. Uses heavy template metaprogramming and Boost preprocessor macros, composes projections safely, and preserves zero-cost calls in common cases. Prototype is used in production libraries and the slides and code are on GitHub.
AI-written summary · about
chapters (11)
- 0:00Overengineering max(a,b)
- 1:09Generic max function
- 3:17Strict weak order
- 7:32Mixed comparisons
- 11:46Integer comparison pitfalls
- 15:59Reference handling
- 26:12Clamp and projection safety
- 34:20Generic composition
- 52:10Lifetime annotations
- 1:04:09Language design critique
- 1:08:01Conclusion
related talks
59mThe Most Average Function There Is
55mI Wish I Could Use C++ 1x/y/z
21mSafe Numerics Library
41m“Avoiding Disasters with Strongly Typed C++”
01h 35mMongrel Monads, Dirty, Dirty, Dirty
01h 01mRethinking the Way We Do Templates in C++
01h 05mA C++ Approach to Physical Units
32mC++ Standard Library "Little Things”
