Get a template with a minimum common base class in the template

Let's say I have a function that takes two different template arguments:

template<typename T, typename U>
void fun(T t, U u);

      

Types T and U are part of the same inheritance tree. I would like to get the most specific class that they both inherit.

typedef /*something*/ shared_parent;

      

For example, if the type T

and the type U

are the same type, I want that type. If the type T

inherits from the type U

, I want the type U

. If Type T

and type U

inherit from the same parent, then I want that parent.

If the types T

and U

are not part of the inheritance tree, I do not care what happens.

+3


source to share





All Articles