Traits
Artur Skawina
art.08.09 at gmail.com
Sun Oct 13 08:10:43 PDT 2013
On 10/13/13 02:25, luminousone wrote:
> On Saturday, 12 October 2013 at 23:48:56 UTC, Artur Skawina wrote:
>> template isBaseOf(BASE, C) {
>> enum isBaseOf = {
>> static if (is(C S == super))
>> foreach (A; S)
>> static if (isBaseOf!(BASE, A))
>> return true;
>> return is(C==BASE);
>> }();
>> }
>>
>> Sorry, didn't test this properly; going to blame the dlang is-expression docs.
>> It's not like D has multiple inheritance, so using "base classes" (plural)
>> is very misleading...
> yea "is" can be a lil confusing, especially that "is( C S == super)" expression.
>
> I take it that "is( C S == super)" is only the bases directly listed for inheritance by the class and not the bases bases as well? which is the reason for the change you made their?
Yes, D supports only single inheritance, so there can never be more than
one "super" class (plus interfaces). I'm not using classes in D often and
when I looked up that is-expr syntax, the wrong doc confused me. It should
say "base class" (or "super class"), not "base classes".
artur
More information about the Digitalmars-d-learn
mailing list