#include <climits>
#include <concepts>
#include <limits>
#include <optional>
#include <type_traits>
Go to the source code of this file.
|
template<class T > |
bool | AdditionOverflow (const T i, const T j) noexcept |
|
template<class T > |
std::optional< T > | CheckedAdd (const T i, const T j) noexcept |
|
template<class T > |
T | SaturatingAdd (const T i, const T j) noexcept |
|
template<std::integral T> |
constexpr std::optional< T > | CheckedLeftShift (T input, unsigned shift) noexcept |
| Left bit shift with overflow checking. More...
|
|
template<std::integral T> |
constexpr T | SaturatingLeftShift (T input, unsigned shift) noexcept |
| Left bit shift with safe minimum and maximum values. More...
|
|
◆ AdditionOverflow()
template<class T >
bool AdditionOverflow |
( |
const T |
i, |
|
|
const T |
j |
|
) |
| |
|
noexcept |
◆ CheckedAdd()
template<class T >
std::optional< T > CheckedAdd |
( |
const T |
i, |
|
|
const T |
j |
|
) |
| |
|
noexcept |
◆ CheckedLeftShift()
template<std::integral T>
constexpr std::optional< T > CheckedLeftShift |
( |
T |
input, |
|
|
unsigned |
shift |
|
) |
| |
|
constexprnoexcept |
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 59 of file overflow.h.
◆ SaturatingAdd()
template<class T >
T SaturatingAdd |
( |
const T |
i, |
|
|
const T |
j |
|
) |
| |
|
noexcept |
◆ SaturatingLeftShift()
template<std::integral T>
constexpr T SaturatingLeftShift |
( |
T |
input, |
|
|
unsigned |
shift |
|
) |
| |
|
constexprnoexcept |
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 78 of file overflow.h.