carb::cpp::popcount_constexpr

Defined in carb/cpp/Bit.h

template<class T, std::enable_if_t<std::is_unsigned<T>::value, bool> = true>
constexpr int carb::cpp::popcount_constexpr(T val) noexcept

Returns the number of 1 bits in the value of x.

Note

Unlike popcount(), this function is constexpr as it does not make use of intrinsics. Therefore, at runtime it is recommended to use popcount() instead of this function.

Parameters

val[in] The unsigned integer value to test.

Returns

The number of 1 bits in the value of val.