#include <iostream>
#include <type_traits>
using namespace std;
//实现求阶乘
template<unsigned n>
struct fac : std::integral_constant<int, n*fac<n - 1>::value>{};
template<>
struct fac<0> : std::integral_constant<int, 1>{};
int main()
{
cout << fac<5>::value << endl;
return 0;
}
原文:https://www.cnblogs.com/xpylovely/p/12205375.html