我在这里找到了一段代码Printing 1 to 1000 without loop or conditionals
请问有人可以解释一下编译时递归是如何工作的吗,我在谷歌上没找到相关信息
// compile time recursion
template<int N> void f1()
{
f1<N-1>();
cout << N << '\n';
}
template<> void f1<1>()
{
cout << 1 << '\n';
}
int main()
{
f1<1000>();
}
谢谢!
if
关键字... - Matthieu M.