diff --git a/maths.cpp b/maths.cpp index 9b2e43eb..892b5b66 100644 --- a/maths.cpp +++ b/maths.cpp @@ -75,7 +75,7 @@ template uint64_t log2 (uint64_t); template double rootsquare (T a, T b) - { return sqrt (pow2 (a) + pow2 (b)); } + { return sqrt (util::pow2 (a) + util::pow2 (b)); } template double rootsquare (double, double); diff --git a/maths.hpp b/maths.hpp index f9bb080d..b839e526 100644 --- a/maths.hpp +++ b/maths.hpp @@ -26,14 +26,16 @@ #include #include -template -T -abs (T value) -{ return value > 0 ? value : -value; } +/////////////////////////////////////////////////////////////////////////////// namespace util { - template T abs (T t) { return ::abs (t); } + template + T + abs [[gnu::const]] (T t) + { + return t > 0 ? t : -t; + } } @@ -47,17 +49,11 @@ namespace util { { return value * value; } } -template constexpr T pow2 [[gnu::const]] (T value) { return util::pow2 (value); } - //----------------------------------------------------------------------------- -template -constexpr T -pow [[gnu::const]] (T x, unsigned y); - namespace util { - template - constexpr T pow (T x, unsigned y) { return ::pow (x, y); } + constexpr T + pow [[gnu::const]] (T x, unsigned y); } diff --git a/maths.ipp b/maths.ipp index a62eeb7c..ad897e54 100644 --- a/maths.ipp +++ b/maths.ipp @@ -26,12 +26,12 @@ //----------------------------------------------------------------------------- template constexpr T -pow (T x, unsigned y) +util::pow (T x, unsigned y) { if (y == 0) return T(1); - return x * ::pow (x, y - 1); + return x * util::pow (x, y - 1); }