【发布时间】:2023-03-31 04:19:01
【问题描述】:
cycle定义中的递归在哪里中断?
#include <iostream>
using namespace std;
template<typename T>
struct Recursive
{
using cycle = struct X : Recursive<X> {}; // would work for Recursive<T> as well
};
int main()
{
Recursive<int> x;
return 0;
}
令我惊讶的是上面的代码compiles - 它是一段有效的代码吗?如果是,cycle 类型的含义(简要说明)是什么?
【问题讨论】:
标签: c++ templates c++11 crtp incomplete-type