C++20 provides a new <bit> header which provides some bit operations including popcount.
std::popcount(0u); // 0
std::popcount(1u); // 1
std::popcount(0b1111'0000u); // 4
C++20
C++20 provides a new <bit> header which provides some bit operations including popcount.
std::popcount(0u); // 0
std::popcount(1u); // 1
std::popcount(0b1111'0000u); // 4