Re: Conditional Inheritance

2013-07-14 Thread lomereiter
Thanks. Now I realise that D is much less intuitive than C++.

Re: Conditional Inheritance

2013-07-14 Thread Timon Gehr
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 i

Re: Conditional Inheritance

2013-07-14 Thread JS
On Sunday, 14 July 2013 at 09:52:29 UTC, Simen Kjaeraas wrote: 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(!isBa

Re: Conditional Inheritance

2013-07-14 Thread Simen Kjaeraas
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 f

Re: Conditional Inheritance

2013-07-14 Thread Simen Kjaeraas
On 2013-07-14, 07:00, JS wrote: I need to conditionally inherit: interface A(T) : conditionallyInherit!(isBasicType!T, B); A!(double) will inherit B but A!(mytype) won't. template conditionallyInherit(bool choice, T...) { static if (choice) { alias conditionallyInherit = T; }

Re: Conditional Inheritance

2013-07-14 Thread lomereiter
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. Why isn't a dummy interface acceptable?

Re: Conditional Inheritance

2013-07-13 Thread JS
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. i

Re: Conditional Inheritance

2013-07-13 Thread JS
On Sunday, 14 July 2013 at 05:28:08 UTC, lomereiter wrote: This should work: template conditionallyInherit(bool inherit, T) { static if (inherit) alias T conditionallyInherit; else interface conditionallyInherit {} } Thanks, I tried something similar but it didn't work

Re: Conditional Inheritance

2013-07-13 Thread lomereiter
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))

Re: Conditional Inheritance

2013-07-13 Thread lomereiter
This should work: template conditionallyInherit(bool inherit, T) { static if (inherit) alias T conditionallyInherit; else interface conditionallyInherit {} }

Re: Conditional Inheritance

2013-07-13 Thread JS
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.

Conditional Inheritance

2013-07-13 Thread JS
I need to conditionally inherit: interface A(T) : conditionallyInherit!(isBasicType!T, B); A!(double) will inherit B but A!(mytype) won't.