Finding Super class from Derived Class at compile time

LeqxLeqx mitchelldlarson at protonmail.ch
Mon Apr 15 05:06:54 UTC 2019


Hello!

I have a question regarding attempting to access the super class 
of a derived class at compile time.

Specifically, if I have:

     class A { }
     class B : A { }

     void func(T)()
     {
       /+ find super-class of T +/
     }

     int main ()
     {
       func!B; /+ func would find A +/
       return 0;
     }

in `func(T)()' how would I (if it is possible) check what class T 
derives from? So `func!B' would be able to find `A'? I've looked 
through the __traits options but none of them seem to be able to 
do what I need. Unfortunately (for me anyways), __traits(parent, 
...) returns the module, not the super class.

Is this at all possible (at compile time)?

Thank you


More information about the Digitalmars-d-learn mailing list