template<class T>
class Test
{
public:
template<class Other>
class show
{
public:
typedef Test<Other> other;
};
};
template<typename T, class A = std::allocate<T> >
class SList
{
//....
struct Node
{
//....
};
//typedef A::show<Node>::other alloc; 出错
typedef typename A::template show<Node>::other alloc;
};
在采用typename 消除歧义中,我们有时必须告诉编译器,某个嵌套的名字是一个类型名字
(而不是一个非类型名字),这样编译器才能正确执行解析工作。对于嵌套的模板名字也同样存
这样的情况