有这个代码:
template< typename T>
class A
{
public:
typedef std::map<int, typename T*>::const_iterator Const_iterator;
};
g++ 7.3.0 抛出此错误:
main.cpp:8:36: error: template argument 2 is invalid typedef std::map<int, typename T*>::const_iterator Const_iterator;
是什么原因?
尝试
或者
您有两个错误 - 首先,
typename当T不需要完全声明的类型参数时,其次,需要指示从属名称是一种类型。