How about a special null template parameter?
Enamex via Digitalmars-d
digitalmars-d at puremagic.com
Fri Aug 19 16:41:16 PDT 2016
On Friday, 19 August 2016 at 23:12:39 UTC, Engine Machine wrote:
> 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?
Um, not sure what you mean. This isn't suggesting adding
anything; it's already legal/compiles.
More information about the Digitalmars-d
mailing list