carb::cpp::has_single_bit

Defined in carb/cpp/Bit.h

template<class T, std::enable_if_t<detail::IsUnsignedIntegral<T>::value, bool> = false>
constexpr bool carb::cpp::has_single_bit(T val) noexcept

Checks if a given value is an integral power of 2.

Template Parameters

T – An unsigned integral type

Parameters

val – An unsigned integral value

Returns

true if val is not zero and has a single bit set (integral power of two); false otherwise.