给定一个只有一个参数的模板类,我可以为特定的特化定义实现:
template<int N>
struct Foo {
Foo( );
};
Foo<2>::Foo( ) { //works (on MS Visual 2012, even though it's not the most correct form)
}
对于多参数模板,是否可以为部分特化定义实现?
template <class X, int N>
struct Bar {
Bar( );
};
template <class X>
Bar<X,2>::Bar( ) { //error
}
if (N == 2) {
- gerardw