私は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'