std::bit_ceil

From cppreference.com
< cpp‎ | numeric
Defined in header <bit>
template< class T >
constexpr T bit_ceil(T x);
(since C++20)

Calculates the smallest integral power of two that is not smaller than x. If that value is not representable in T, the behavior is undefined.

This function is constexpr only if the result is representable in T.

This overload only participates in overload resolution if T is an unsigned integer type (that is, unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long, or an extended unsigned integer type).

Parameters

x - values of unsigned integer type

Return value

The smallest integral power of two that is not smaller than x.

Exceptions

(none)

Example