#include <util/check.h>
#include <climits>
#include <concepts>
#include <limits>
#include <optional>
#include <type_traits>
Go to the source code of this file.
◆ AdditionOverflow()
| bool AdditionOverflow |
( |
const T |
i, |
|
|
const T |
j |
|
) |
| |
|
noexcept |
◆ CeilDiv()
Integer ceiling division (for unsigned values).
Computes the smallest integer q such that q * divisor >= dividend. Both dividend and divisor must be unsigned, and divisor must be non-zero.
The implementation avoids overflow that can occur with (dividend + divisor - 1) / divisor.
Definition at line 70 of file overflow.h.
◆ CheckedAdd()
| std::optional< T > CheckedAdd |
( |
const T |
i, |
|
|
const T |
j |
|
) |
| |
|
noexcept |
◆ CheckedLeftShift()
Left bit shift with overflow checking.
- Parameters
-
| input | The input value to be left shifted. |
| shift | The number of bits to left shift. |
- Returns
- (input * 2^shift) or nullopt if it would not fit in the return type.
Definition at line 83 of file overflow.h.
◆ SaturatingAdd()
| T SaturatingAdd |
( |
const T |
i, |
|
|
const T |
j |
|
) |
| |
|
noexcept |
◆ SaturatingLeftShift()
Left bit shift with safe minimum and maximum values.
- Parameters
-
| input | The input value to be left shifted. |
| shift | The number of bits to left shift. |
- Returns
- (input * 2^shift) clamped to fit between the lowest and highest representable values of the type T.
Definition at line 102 of file overflow.h.
◆ TrySub()