Add two integers, saturating instead of overflowing.
Declared in <util/overflow.h>
template<std::integral T>
[[nodiscard]]
T
SaturatingAdd(
T const i,
T const j) noexcept;
The sum i + j, clamped to the lowest or highest representable value of T when the addition would overflow.
The return value should not be discarded.
| Name | Description |
|---|---|
| i | The first addend. |
| j | The second addend. |