Overview of base/numerics library
mainThe base/numerics library is a dependency-free, header-only C++ library providing templates for safe and performant numeric operations and conversions. It is organized into several specialized headers:
checked_math.h: ProvidesCheckedNumericfor arithmetic and conversions that detect errors like overflow or truncation.clamped_math.h: ProvidesClampedNumericfor fast, non-sticky saturating (clamped) arithmetic.safe_conversions.h: ProvidesStrictNumericand various casting templates for safe type conversions.safe_math.h: A convenience header that includes all the above.
Type Coercion Priority: When using these types, they implicitly convert from standard C numeric types. The coercion priority is:
StrictNumeric$\rightarrow$ClampedNumeric$\rightarrow$CheckedNumeric.