Add two integers, checking for overflow.
Declared in <util/overflow.h>
template<class T>
[[nodiscard]]
std::optional<T>
CheckedAdd(
T const i,
T const j) noexcept;
The sum i + j, or std::nullopt if the addition would overflow T.
The return value should not be discarded.
| Name | Description |
|---|---|
| i | The first addend. |
| j | The second addend. |