xte::sub()

Defined in header <xte/math/sub.hpp>

Computes the difference of multiple values, avoiding undefined behavior from signed integer wrapping. Casts all arguments to their mutual common type. Does not prevent undefined behavior from floating-point subtraction.


Definition

[[nodiscard]] constexpr auto sub(xte::is_number auto augend, xte::is_number auto... addends) noexcept;



Example

static_assert(xte::sub(INT_MIN, 1) == INT_MAX);
[View in Compiler Explorer]