Example with compile-time computation: #include <iostream> template<int N> struct F { static const int value = N * F<N - 1>::value; }; template<> struct F<0> { static const int value = 1; }; int main() { std::cout << F<10>::value << "\n"; }