#include <climits>
#include <limits>
#include <optional>
Go to the source code of this file.
|
| template<typename T > |
| constexpr std::optional< T > | CheckedLeftShift (T input, unsigned shift) noexcept |
| | Left bit shift with overflow checking. More...
|
| |
| template<typename T > |
| constexpr T | SaturatingLeftShift (T input, unsigned shift) noexcept |
| | Left bit shift with safe minimum and maximum values. More...
|
| |
◆ CheckedLeftShift()
template<typename 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 20 of file overflow.h.
◆ SaturatingLeftShift()
template<typename 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 47 of file overflow.h.