且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 C++ 模板类中,我可以使用相同的名称对模板参数进行 typedef 吗?

更新时间:2022-02-05 23:04:53

在 C++11 中是不允许的.

It is not allowed in C++11.

typedef 是一个声明.(见第 7.1.3 节)

A typedef is a declaration. (see section 7.1.3)

template 参数不能在其作用域(包括嵌套作用域)内重新声明.(见第 14.6.1.6 节)

A template parameter can't be redeclared within its scope (including nested scopes). (see section 14.6.1.6)

C++11 草案标准 n3242