Conditional Inheritance

Simen Kjaeraas simen.kjaras at gmail.com
Sun Jul 14 02:52:11 PDT 2013


On 2013-07-14, 07:40, JS wrote:

> On Sunday, 14 July 2013 at 05:30:57 UTC, lomereiter wrote:
>> On Sunday, 14 July 2013 at 05:04:37 UTC, JS wrote:
>>> and while I'm at it I need to conditionally constrain types.
>>>
>>> interface A(T) where(!isBasicType!T, (T : B));
>>>
>>> which is suppose to require T to inherit from B if T is not basic type.
>>
>> interface A(T) if (isBasicType!T || is(T : B))
>
> Thanks, works. I remember seeing code like this somewhere but couldn't  
> find any docs about it.

Here. I admit there should probably be more examples, and perhaps also
some info on the classes/interfaces/structs & unions pages.

http://dlang.org/template.html#Constraint

-- 
Simen


More information about the Digitalmars-d-learn mailing list