Conditional Inheritance

Timon Gehr timon.gehr at gmx.ch
Sun Jul 14 08:48:36 PDT 2013


On 07/14/2013 11:37 AM, lomereiter wrote:
>> I assume that you template ends up creating a dummy interface though
>> and this isn't really acceptable.
>
> Yes, it does. Once ':' is typed, some inheritance must occur.
>

Nope.

template Seq(T...){ alias T Seq; }

class C : Seq!(){ }


> Why isn't a dummy interface acceptable?

It creates unnecessary bloat.

template conditionallyInherit(bool inherit, T) {
     static if(inherit) alias T conditionallyInherit;
     else alias Seq!() conditionallyInherit;
}



More information about the Digitalmars-d-learn mailing list