SaturatingLeftShift

Left bit shift with safe minimum and maximum values.

Synopsis

Declared in <util/overflow.h>

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

Return Value

(input * 2^shift) clamped to fit between the lowest and highest representable values of the type T.

Parameters

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