llvm::popcount

Count the number of set bits in a value. Ex. popcount(0xF000F000) = 8 Returns 0 if Value is zero.

Synopsis

Declared in <llvm/ADT/bit.h>

template<typename T>
[[nodiscard]]
constexpr
int
popcount(T Value) noexcept;

Return Value

Number of set bits in Value, or 0 if Value is zero.

NOTE

The return value should not be discarded.

Parameters

NameDescription
ValueUnsigned value whose set bits are counted.