The current status of D?
Timon Gehr
timon.gehr at gmx.ch
Fri Dec 2 09:38:23 PST 2011
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.
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(); }
More information about the Digitalmars-d
mailing list