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