A
Anonymous
I want to be able to restrict the set of classes for which a template
class can be instantiated (i.e enforce that all instantiation MUST be
for classes taht derive from a base type BaseType).
This occured to me immediately, but use of a dummy variable is not
elegant - are there other (more elegant) ways of doing this?
template <class DerivedType>
class MyClass
{
public:
MyClass():m_type(*DerivedType){};
~MyClass(){}
private:
BaseType * m_type ; //dummy variable
};
class can be instantiated (i.e enforce that all instantiation MUST be
for classes taht derive from a base type BaseType).
This occured to me immediately, but use of a dummy variable is not
elegant - are there other (more elegant) ways of doing this?
template <class DerivedType>
class MyClass
{
public:
MyClass():m_type(*DerivedType){};
~MyClass(){}
private:
BaseType * m_type ; //dummy variable
};