| 22 | |
| 23 | template <class T> |
| 24 | [[nodiscard]] std::optional<T> CheckedAdd(const T i, const T j) noexcept |
| 25 | { |
| 26 | if (AdditionOverflow(i, j)) { |
| 27 | return std::nullopt; |
| 28 | } |
| 29 | return i + j; |
| 30 | } |
| 31 | |
| 32 | template <class T> |
| 33 | [[nodiscard]] T SaturatingAdd(const T i, const T j) noexcept |