How about a special null template parameter?

Engine Machine via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 19 16:12:39 PDT 2016


On Friday, 19 August 2016 at 22:20:09 UTC, Enamex wrote:
> On Friday, 19 August 2016 at 18:25:06 UTC, Engine Machine wrote:
>> [...]
>
> Something like this:
>
> class Type(T: typeof(null)) { //< L1 (specialization)
>     int x;
> }
>
> class Dog {}
>
> class Type(T) : Type!(typeof(null)) { //< L2 (`typeof(null)`)
>     static if(is(T: Dog)) //< L3 (`is(MyType: IntendedType)` or 
> `is(MyType == ExactType)`)
>         int y;
> }
>
> What you're looking for is "specialization", on line "L1". Also 
> some corrections on lines "L2" and "L3"

How is this any different, besides adding meaningless complexity, 
to inheritence as it already is?


More information about the Digitalmars-d mailing list