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

Name

Description

Value

Unsigned value whose set bits are counted.

Created with MrDocs