I was trying to rewrite the Factorial implementation using constexpr function but for some reason I have no idea why I get a compile error:
constexpr
You need to define a specialization of the template function to stop the recursion at the compile time rather than runtime, just as your struct version did.
template int f2() { return N * f2(); } template <> int f2<0>() { return 1; }