xte::add_checked()

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

Computes the sum (wrapped in xte::opt {}) of multiple values (added sequentially). Returns xte::null if the result of any intermediate operation cannot be represented.


Definition

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



Example

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