maths: make pow constexpr
This commit is contained in:
parent
af7f01efd3
commit
e4a93fe23c
@ -38,13 +38,8 @@ align (T value, U size) {
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T
|
constexpr T
|
||||||
pow (T x, unsigned y)
|
pow (T x, unsigned y)
|
||||||
{
|
{
|
||||||
T v = 1;
|
return y == 0 ? 1 : x * pow (x, y - 1);
|
||||||
|
|
||||||
for (unsigned i = 1; i <= y; ++i)
|
|
||||||
v *= x;
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user