muu/popcount.h file

Contains the definitions of muu::popcount() and muu::has_single_bit().

Namespaces

namespace muu
The root namespace for all muu functions and types.

Functions

template <typename T>
auto has_single_bit(T val) -> bool constexpr noexcept
Checks if an integral value has only a single bit set.
template <typename T>
auto popcount(T val) -> int constexpr noexcept
Counts the number of set bits (the 'population count') of an unsigned integer.