From 964d16f907dd74adadb5beaec4a9446438f0f169 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 18 Nov 2016 01:14:33 +0100 Subject: [PATCH] Math/Algorithm: CountBits now returns a std::size_t instead of a T --- include/Nazara/Math/Algorithm.hpp | 2 +- include/Nazara/Math/Algorithm.inl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Math/Algorithm.hpp b/include/Nazara/Math/Algorithm.hpp index 45281bb50..f138a8fc9 100644 --- a/include/Nazara/Math/Algorithm.hpp +++ b/include/Nazara/Math/Algorithm.hpp @@ -37,7 +37,7 @@ namespace Nz { template /*constexpr*/ T Approach(T value, T objective, T increment); template constexpr T Clamp(T value, T min, T max); - template /*constexpr*/ T CountBits(T value); + template /*constexpr*/ std::size_t CountBits(T value); template constexpr T FromDegrees(T degrees); template constexpr T FromRadians(T radians); template constexpr T DegreeToRadian(T degrees); diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index b61d82916..02ede739a 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -147,10 +147,10 @@ namespace Nz template //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;