CheckedLeftShift

Left bit shift with overflow checking.

Synopsis

Declared in <util/overflow.h>

template<std::integral T>
constexpr
std::optional<T>
CheckedLeftShift(
    T input,
    unsigned int shift) noexcept;

Return Value

(input * 2^shift) or nullopt if it would not fit in the return type.

Parameters

NameDescription
inputThe input value to be left shifted.
shiftThe number of bits to left shift.