Home

Anonymous wrote:
> 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
> };

The combination of 'Boost::enable_if' with 'base_or_derived' temlplate
helpers should essentially do what you ask, I think.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

previous
next

Understanding closures
Help with an Assignment(newb help)
Re: A big problem with _name_ == '_main_'
Reading text files where last line has no EOL
Re: encryption problem
Pajacyk
Dzieci Niczyje
Fundacja Iskierka
Rodzic Po Ludzku
Niechciane i Zapomniane