maths: make pow constexpr

This commit is contained in:
Danny Robson 2015-01-28 14:57:37 +11:00
parent af7f01efd3
commit e4a93fe23c

View File

@ -38,13 +38,8 @@ align (T value, U size) {
//-----------------------------------------------------------------------------
template <typename T>
T
constexpr T
pow (T x, unsigned y)
{
T v = 1;
for (unsigned i = 1; i <= y; ++i)
v *= x;
return v;
return y == 0 ? 1 : x * pow (x, y - 1);
}