Finding Super class from Derived Class at compile time

LeqxLeqx mitchelldlarson at protonmail.ch
Tue Apr 16 01:18:01 UTC 2019


On Monday, 15 April 2019 at 22:45:59 UTC, Adam D. Ruppe wrote:
> On Monday, 15 April 2019 at 05:20:37 UTC, Ali Çehreli wrote:
>> BaseClassesTuple and friends:
>>
>>   https://dlang.org/phobos/std_traits.html
>
> And the implementation of that is the `is` expression
>
> https://dlang.org/spec/expression.html#IsExpression
>
> specifically, with the `super` keyword.
>
> static if (is(YourClass ListOfBaseTypes == super))
>    // use ListOfBaseTypes here; you can foreach, index, or 
> slice it to get what you are looking for.

That's perfect. Thank you both so much!


More information about the Digitalmars-d-learn mailing list