在下面的代码中:
template<typename T>
struct X {};
int main()
{
X<int()> x; // what is the type of T ?
}
T 的类型是什么?我在 boost
来源中看到了类似的内容。
最佳答案
考虑函数 int func()
。它有一个函数类型 int(void)
。正如 C++ 标准在 4.3/1 中所说,它可以隐式转换为指针类型,但在这种情况下不需要进行这种转换,因此 T
的函数类型为 int(void)
,而不是指向它的指针。
关于c++ - T的类型是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3530470/