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