Can I extract the type parameter from the derived class? Something like this:
template<typename T>
class A {
...
};
struct TheType {};
class B : public A<TheType> {
...
};
template<typename DerivedClass>
class C {
// If DerivedClass is B
// Can I extract the type parameter T of B:A<T> inside of C?
DerivedClass elem;
};
You can add a type
in A
:
template<typename T>
class A {
protected:
using type = T;
...
};
Then you can use typename DerivedClass::type
in C
.