fork download
  1. #include <iostream>
  2.  
  3. template<const unsigned N>
  4. struct Factorial
  5. {
  6. enum V
  7. {
  8. val = N * Factorial<N-1>::val
  9. };
  10. };
  11. template<>
  12. struct Factorial<1>
  13. {
  14. enum V
  15. {
  16. val = 1
  17. };
  18. };
  19.  
  20. int main()
  21. {
  22. std::cout << Factorial<5>::val << std::endl;
  23. }
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
120