我想专门化以下模板类的类型参数,它有一个类型参数和一个模板模板参数:
template <
typename T,
template <typename E> class Foo
> class Bar;
我尝试了在以下每个片段的最后一行添加和/或省略.template和的所有排列,但没有一个编译:typename
1.)
template <
template <typename E> class Foo
> class Bar<int, Foo<typename E>>;
2.)
template <
template <typename E> class Foo
> class Bar<int, Foo.template <typename E>>;
3.)
template <
template <typename E> class Foo
> class Bar<int, Foo<E>>;
4.)
template <
template <typename E> class Foo
class Bar<int, Foo.template <E>>;
为什么它们中的任何一个都不起作用?
关于每个适用片段的最后一行:
- 没有
typename澄清E是 class 使用的类型Foo,还是只能在类定义的{}主体中使用此语法Bar? - 没有
template澄清Foo是一个模板,因此阻止编译器解析Foo <为Foo“小于”,或者这种语法只能在类定义的{}主体中使用Bar?
我怎样才能让它工作?