xte::sub_checked()

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

Computes the difference (wrapped in xte::opt {}) of multiple numbers (subtracted sequentially). Casts all arguments to their mutual common type. Returns xte::null if the result of any intermediate operation cannot be represented.


Definition

[[nodiscard]] constexpr auto sub_checked(xte::is_arithmetic auto augend, xte::is_arithmetic auto... addends) noexcept;



Example

static_assert(*xte::sub_checked(1, 2) == 3);
static_assert(!xte::sub_checked(INT_MAX, 1));
[View in Compiler Explorer]