AdditionOverflow

Test whether the sum of two integers would overflow.

Synopsis

Declared in <util/overflow.h>

template<std::integral T>
[[nodiscard]]
bool
AdditionOverflow(
    T const i,
    T const j) noexcept;

Return Value

true if i + j would fall outside the representable range of T, false otherwise.

NOTE

The return value should not be discarded.

Parameters

NameDescription
iThe first addend.
jThe second addend.