The current status of D?

Mehrdad wfunction at hotmail.com
Fri Dec 2 12:57:32 PST 2011


On 12/2/2011 9:38 AM, Timon Gehr wrote:
> On 12/02/2011 05:13 PM, Mehrdad wrote:
>> Actually, regarding my "little problem", why does this given an
>> error/what's the proper way to fix it?
>>
>> class C(T) { inout this(inout(T)) { } }
>> C!T slice(T)(auto ref T c) { return new C!T(c); }
>> void main() { [1, 2, 3, 4, 5].slice(); }
>>
>> //Test.d(2): Error: cannot implicitly convert expression (new C(items))
>> of type inout(C) to Test.C!(int[]).C
>
> 1. File a bug. inout is apparently not resolved properly by DMD in 
> this case.
http://d.puremagic.com/issues/show_bug.cgi?id=7053

> 2. Apply this workaround to make the compiler shut up (and probably to 
> make your code less bloated by extraneous template instances as well 
> :o)):
>
> class C(T) { inout this(inout(T)) { } }
> inout(C!T) slice(T)(inout T c){ return new C!T(c); }
> void main() { [1, 2, 3, 4, 5].slice(); }
That just propagates it up the stack, though...


More information about the Digitalmars-d mailing list