carb::cpp20::has_single_bit¶
Defined in carb/cpp20/Bit.h
-
template<class
T
, std::enable_if_t<std::is_integral<T>::value && std::is_unsigned<T>::value, bool> = false>
constexpr boolcarb::cpp20
::
has_single_bit
(T val)¶ 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
ifval
is not zero and has a single bit set (integral power of two);false
otherwise.