Bitcoin ABC 0.32.4
P2P Digital Currency
Functions
overflow.h File Reference
#include <climits>
#include <limits>
#include <optional>
Include dependency graph for overflow.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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...
 

Function Documentation

◆ CheckedLeftShift()

template<typename T >
constexpr std::optional< T > CheckedLeftShift ( input,
unsigned  shift 
)
constexprnoexcept

Left bit shift with overflow checking.

Parameters
inputThe input value to be left shifted.
shiftThe 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.

Here is the caller graph for this function:

◆ SaturatingLeftShift()

template<typename T >
constexpr T SaturatingLeftShift ( input,
unsigned  shift 
)
constexprnoexcept

Left bit shift with safe minimum and maximum values.

Parameters
inputThe input value to be left shifted.
shiftThe 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.

Here is the call graph for this function: