【发布时间】:2015-11-27 00:41:43
【问题描述】:
我正在尝试在类模板的特化中特化一个函数,但找不到正确的语法:
template< typename T >
struct Foo {};
template<>
struct Foo< int >
{
template< typename T >
void fn();
};
template<> template<>
void Foo< int >::fn< char >() {} // error: too many template-parameter-lists
在这里,我尝试将fn 专门用于char,它位于Foo 的内部,专门用于int。但是编译器不喜欢我写的东西。那么正确的语法应该是什么?
【问题讨论】:
标签: c++ templates template-specialization