xte::add()

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

Computes the sum 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 addition.


Definition

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



Example

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