c++ - 模板特化与另一个模板

标签 c++ templates template-specialization template-classes

假设我有两个模板类

template < class T >
class Foo
{
    /**/
};

template < class T >
class Bar
{
     /**/
};

我怎样才能专攻FooBar<T> ?? 语法是什么?? 是吗

template<>
template<class T>
class Foo<Bar<T>>
{ /**/ };

template<class T>
class Foo<Bar<T>>
{ /**/ };

或任何其他语法??

最佳答案

语法是最后一个:

template<class T>
class Foo<Bar<T>>
{
     /* Your implementation of this partial specialization. */
};

关于c++ - 模板特化与另一个模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40973522/

相关文章:

C++如何获取存储在空指针中的地址?

python - 如何使用 Django 中间件在所有 Django 上下文中插入一些文本

c++ - 专门的模板类循环依赖

函数中的c++模板

c++ - 在构造函数只需要前向声明的模板基类中的虚函数中使用前向声明的类?

c++ - C++模板模棱两可的实例化

c++ - 为单参数模板调用的特定值调用具有更多参数的调用模板特化

c++ - 覆盖派生类中的枚举值

c++ - C3859 : Virtual memory range for PCH exceeded

c++ - 如果句柄立即关闭,RegisterWaitForSingleObject 有时会崩溃