模板模板部分专用化的正确语法是什么
what is correct syntax for partial specialization of template template
嗨,任何人都可以解释模板模板部分专业化的正确语法是什么? 甚至可能吗? 任何帮助都非常感谢
template < typename A >
class X
{
};
template < typename B >
class Y
{
};
template < template< typename > class U, class T >
class Z
{
// there are other methods in class which i don't want to replicate
void func(); // want to specialize this for class X
};
template < template< typename > class U, class T >
void Z< U, T >::func()
{
std::cout << " this is done ";
}
// specialize this for X
template < template< typename > class U, class T >
void Z< X, T >::func()
{
}
您不能只专门化类模板的一部分。当您部分专用化类模板时,您需要提供整个声明,而不仅仅是单个函数。
而且,您不能部分专用化函数模板。
你也许可以通过继承做你想做的事。可以在基类中收集共享方法,然后定义一个模板化派生类,该类对具有例外的方法具有部分专用化。
相关文章:
- C++避免重复声明的语法是什么
- 使用基类指针调用基类的值构造函数的语法是什么?
- 这行/语法是什么意思?
- 初始化对象以在 C++08 中作为参数传递的首选语法是什么?
- 将引用绑定到指针的语法是什么?(各种)
- 这个typedef和转换运算符语法是什么意思
- 此语法是什么意思.(::*).
- 将显式指定的函数模板重载作为模板参数传递的正确语法是什么?
- 使用 pybind11 绑定 typedef 类型的正确语法是什么?
- 将此类传递给引用的正确语法是什么?
- 带有约束的可变参数模板的'requires'表达式的语法是什么?
- 在TensorFlow C++中用于feed_dict的语法是什么?
- 调用模板化类内的枚举类枚举器的正确语法是什么
- 返回没有 typedef 的成员函数指针的语法是什么?
- 将强制转换运算符重载到 std::map 的正确语法是什么
- 这种增量语法是什么意思
- 返回结构的方法的正确语法是什么
- C 中的(*)语法是什么意思
- 堆栈(int = 10),这个语法是什么意思(C++)
- variadic模板阵列参考参数的语法是什么?