diff --git a/maths.cpp b/maths.cpp index 8891d707..59fd2144 100644 --- a/maths.cpp +++ b/maths.cpp @@ -24,22 +24,6 @@ #include -/////////////////////////////////////////////////////////////////////////////// -template -bool -util::is_pow2 (T value) -{ - typedef typename std::enable_if::value, bool>::type return_type; - return (return_type)(value && !(value & (value - 1))); -} - - -template bool util::is_pow2 (uint8_t); -template bool util::is_pow2 (uint16_t); -template bool util::is_pow2 (uint32_t); -template bool util::is_pow2 (uint64_t); - - /////////////////////////////////////////////////////////////////////////////// template T diff --git a/maths.hpp b/maths.hpp index 1a4c5214..38205e33 100644 --- a/maths.hpp +++ b/maths.hpp @@ -67,8 +67,12 @@ namespace util { //------------------------------------------------------------------------- template - bool - is_pow2 (T value); + constexpr + std::enable_if_t::value, bool> + is_pow2 [[gnu::const]] (T value) + { + return value && !(value & (value - 1)); + } //-----------------------------------------------------------------------------