Skip to content
Snippets Groups Projects
Commit 7e070e1c authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[ML] A MSVC friendly alternative to MathLib::pow().

parent 4d5268c5
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment