【发布时间】:2012-01-27 12:47:21
【问题描述】:
有没有办法让这段代码工作?
template<typename T> class test{
public:
template<typename T2> static void f(){
cout<<"generic"<<endl;
}
template<> static void f<void>(){ //specialization of static method for template T2, within generic class template with argument T
cout<<"void"<<endl;
}
};
如果不是,是不是因为它算作函数的部分模板特化?
【问题讨论】:
-
不是我要问的。在那里, struct X 没有模板化。我试图将 f 移到类定义之外,但它也不起作用。
-
另外,请参阅 [this][1] 帖子。 [1]:stackoverflow.com/questions/1723537/…
-
@Brian:也不是这样。