Suppose I have the following classes:
struct baseA {
virtual int foo() {return 0;}
};
struct baseB {
virtual int bar() {return 1;}
};
struct derived : public baseA, public baseB {
typedef std::tuple<baseA, baseB> base_types;
virtual int buzz() {return 2;}
};
And I want to get the base classes of derived
by template, I can use code like this:
template <typename T>
struct basetraits{
typedef T::base_types types;
};
std::tuple_element<0,basetraits<derived>::types>::type
std::tuple_element<1,basetraits<derived>::types>::type
If I do not define base_types
in the derived
class or use some macro, is it possible to get the baseA
and baseB
by other methods?