Math/Algorithm: CountBits now returns a std::size_t instead of a T
This commit is contained in:
@@ -37,7 +37,7 @@ namespace Nz
|
||||
{
|
||||
template<typename T> /*constexpr*/ T Approach(T value, T objective, T increment);
|
||||
template<typename T> constexpr T Clamp(T value, T min, T max);
|
||||
template<typename T> /*constexpr*/ T CountBits(T value);
|
||||
template<typename T> /*constexpr*/ std::size_t CountBits(T value);
|
||||
template<typename T> constexpr T FromDegrees(T degrees);
|
||||
template<typename T> constexpr T FromRadians(T radians);
|
||||
template<typename T> constexpr T DegreeToRadian(T degrees);
|
||||
|
||||
@@ -147,10 +147,10 @@ namespace Nz
|
||||
|
||||
template<typename T>
|
||||
//TODO: Mark as constexpr when supported by all major compilers
|
||||
/*constexpr*/ inline T CountBits(T value)
|
||||
/*constexpr*/ inline std::size_t CountBits(T value)
|
||||
{
|
||||
// https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan
|
||||
unsigned int count = 0;
|
||||
std::size_t count = 0;
|
||||
while (value)
|
||||
{
|
||||
value &= value - 1;
|
||||
|
||||
Reference in New Issue
Block a user