Getting derived classes

BLS nanali at nospam-wanadoo.fr
Sat Nov 1 12:05:28 PDT 2008


Andrei Alexandrescu schrieb:
> dsimcha wrote:
>> I know that, in std.traits, there's a template that spits out all base 
>> classes
>> for a given class.  Based on reading the source, it seems to work 
>> based on a
>> rather interesting use case for is expressions.  Is there any 
>> equivalent way
>> to do the opposite:  For any given position in a class hierarchy, to 
>> get a
>> tuple of all possible descendants?
> 
> That's not possible in general because in D the derived classes form an 
> open set. I guess it could be done at runtime via reflection (not 
> implemented afaik), but not at compile time.
> 
> Andrei

-> Jacha Wetzel
Here is a simple way of adding __traits based runtime reflection to D 
classes:

http://mainia.de/classinfoex.d
(requires DMD 2.004)



More information about the Digitalmars-d mailing list