Consider the following classes:
class A {};
class B {};
class C {};
class D : public A, public B, public C {};
class E : public A, public C {};
class F : public A {};
I want to write a variable type that only accepts types which derive from both A and B (in this case only D) so that the following hold:
T var;
var = D(); // valid
var = E(); // invalid, does not derive from B
var = F(); // invalid, does not derive from B
I could do the following and use G as my type. G would act as a sort of 'type grouper'.
class G : public A, public B {};
class D : public F, public C {};
However if I want to apply this to any combination of base types or with any number of base types, I would need a large number of these type groupers. Is there a way to implement a multiple base type requirement without manually generating type groupers like I showed?
I do not have a specific use case that requires this, I am purely curious whether this is possible.
EDIT: Accidentally used F twice. Switched to G for the second time.