code:
#include <iostream>
template <int N>
struct Factorial {
enum {
value = N * Factorial<N - 1>::value
};
};
template <>
struct Factorial<0> {
enum {
value = 1
};
};
int main() {
std::cout << Factorial<12>::value << std::endl;
return 0;
}
Compile
g++ -std=c++11 ./template.cpp -o template && ./template
479001600