diff --git a/MathLib/MathTools.h b/MathLib/MathTools.h index be8b7016db7b829002f9f74ed0a4b49f0fe35241..07713af3984cea0ddf0a36d701a8127255207222 100644 --- a/MathLib/MathTools.h +++ b/MathLib/MathTools.h @@ -170,11 +170,25 @@ T fastpow (T base, std::size_t exp) * Template metaprogramming, compile-time version of pow() for integral * exponents. */ +#ifdef WIN32 +template <typename T, T B, unsigned E> +struct POW +{ + static T const value = B * POW<T, B, E-1>::value; +}; + +template <typename T, T B> +struct POW<T, B, 0> +{ + static T const value = 1; +}; +#else // WIN32 template <typename T> inline constexpr T pow(T const x, unsigned const y) { - return (y == 0) ? 1 : x * pow(x, y - 1); -}; + return (y == 0) ? 1 : x * pow(x, y - 1); +} +#endif // WIN32 } // namespace