by arbre · 10y ago · 0 comments
template<int64_t n> int64_t fact() { return n * fact<n-1>(); } template<> int64_t fact<0>() { return 1; }
The book "Modern C++ design" from Alexandrescu extensively covers that kind of stuff.
There might even be a way to use a loop and constexprs.