// Factorial template function from Wikipedia. #include #include // The general case: template struct Factorial { static const int value = N * Factorial::value; }; // The base case of the recursion, via template specialization: template <> struct Factorial<0> { static const int value = 1; }; int main(){ Factorial<5> facBox; std::cout << facBox.value << std::endl; // 120 std::cout << Factorial<10>::value << std::endl; // 3628800 }