我有一个struct
表示特征的:
template<typename T>
struct FooTraits
{
static const NEbool s_implementsFoo = false;
};
我可以用一个类来专门化它,因此:
class Apple {};
template<>
struct FooTraits< Apple >
{
static const NEbool s_implementsFoo = true;
};
FooTraits
但是,如果我希望专门研究的类也被模板化,则目前我无法使用,因此:
template< typename T >
class Fruit {};
template<>
struct FooTraits< Fruit >
{
static const NEbool s_implementsFoo = true;
};
我应该如何表达这最后一段代码,所以任何Fruit< T >
有s_implementsFoo = true
?
目前报告以下错误:
error C3203: 'Fruit' : unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type
error C2955: 'Fruit' : use of class template requires template argument list
see declaration of 'Fruit'
error C2990: 'FooTraits' : non-class template has already been declared as a class template
see declaration of 'FooTraits'