Math/Algorithm: CountBits now returns a std::size_t instead of a T

This commit is contained in:
Lynix 2016-11-18 01:14:33 +01:00
parent 9513d9479a
commit 964d16f907
2 changed files with 3 additions and 3 deletions

View File

@ -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);

View File

@ -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;