I have a polymorphic template MyClass that takes argument T.
template<class T>
class MyClass {...};
I would like to force an inheritance without specifing it in every derieved class, something like:
template<class T, class U : public T>
class MyClass<U> : public MyClass<T>;
Is there a way to do it?
EDIT: For Example If I have
class Base {...};
class Derieved : public Base {...};
Then if the compiler creates MyClass<Derieved>
then it would add
class MyClass<Derieved> : public MyClass<Base>
without specifing it every time I use MyClass with inheritance.
I want to be able to create MyClass with any parameter, but when the parameter inherits from some other class, so will the template.