AFAIK, this is due to older compilers that do not allow you to define constant compilation element data. With C ++ 11 you could do
template<int X, int P> struct Pow { static constexpr int result = X*Pow<X,P-1>::result; }; template<int X> struct Pow<X,0> { static constexpr int result = 1; }; template<int X> struct Pow<X,1> { static constexpr int result = X; }; int main() { std::cout << "pow(3,7) is " << Pow<3,7>::result << std::endl; return 0; }
source share