1
我有一个模板类如何专门为一个类的模板模板参数?
template <class T>
struct TypeText {
static const char *text;
};
和一些专业化的为“文本”成员:
template <> const char* TypeText<int>::text = "INT";
template <> const char* TypeText<long>::text = "LONG";
如何贯彻std::vector<A,B>
没有先验知识约A
和B
专业化?是否有可能从SomeOtherClass<A,B>
不同std::vector<A,B>
?
下不起作用:
template <>
template <class T, class A>
const char* TypeText< std::vector<T,A> >::text = "vector";
您已更改初始模板类。 – pavelkolodin
我错了。这是部分专业化让我感到惊讶。谢谢。 – pavelkolodin
@pavelkolodin BTW:你为什么要指定'std :: vector'的第二个模板参数?如果你真的需要这样做,你也可以为局部特化添加第二个模板参数。 – songyuanyao