Daily bit(e) of C++ | Constexpr vs Undefined Behaviour
Daily bit(e) of C++ #438, Making use of constexpr and compile-time evaluation to eliminate undefined behaviour.
Compile-time constant expressions are not permitted to invoke undefined behaviour. This includes constexpr functions that are evaluated at compile-time.
This property can be used to statically test code, ensuring that the code doesn't invoke undefined behaviour.