Base interfaces tuple

John C johnch_atms at hotmail.com
Sat Mar 15 04:44:09 PDT 2008


I've been trying to write a template that returns a tuple of all base 
interfaces from either a derived class or interface. D2 has 
InterfacesTuple, but it doesn't work on interfaces, nor does it return a 
complete list of base types.

Here's what I'm aiming for:

   interface I1 {}
   interface I2 : I1 {}
   interface I3 : I2 {}
   interface I4 : I3 {}

   writefln(typeid(AllBaseInterfaces!(I4));

Which should produce:
   (I1,I2,I3)

BaseTypeTuple from std.traits seems to be the starting point, and 
recursively calling that template gets successive base types, but 
putting that together into a single template has defeated me. Anyone 
accomplished this?

Cheers,
John.


More information about the Digitalmars-d-learn mailing list