folly::set_n_most_significant_bits

Set the n most significant bits of x, leaving the others unchanged.

Synopsis

Declared in <folly/lang/Bits.h>

template<typename T>
[[nodiscard]]
constexpr
T
set_n_most_significant_bits(
    T x,
    uint32_t n);

NOTE

This function is defined as an Algorithm Function Object (AFO).

Return Value

x with its n most significant bits set.

NOTE

The return value should not be discarded.

Parameters

NameDescription
xThe value to modify.
nThe number of high bits to set.