Getting all base classes [Meta-programming]

Yesterday I ran into a problem how to get all base classes from some class. For instance:

class Object 
{
public:
   Object() = default;
};

class DerivedOne
   : public Object
{
public:
   DerivedOne() = default;
};

class DerivedTwo
   : public Object
   , public DerivedOne
{
public:
   DerivedTwo() = default;
};

I want to get the entire base class for DerivedTwo in typelist => {Object, DerivedOne, Object} This is necessary to inherit the inheritance of the Object class more than once.

Does anyone have such survival or knowledge on how to do this?

+4
source share

Source: https://habr.com/ru/post/1673199/


All Articles