May 14, 2013 Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}} | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | > __ctor is a 'this' call, it needs a this (BTW, I get different errors than > you): Seems like not (see my corrected bug in previous post) > Not sure how you would do that in one line ditto >> Why not use 'this' instead of '__ctor', and make it documented (and >> reliable, ie work in the above case) ? >> I don't see how that could create ambiguity, and that would solve the >> problem raised in this thread. > > > You could do that. It may have some ambiguous syntax implications. I really can't think of any, and I think it would just make sense, given that it'd match the way the function is declared. |
May 14, 2013 Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}} | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timothee Cour | On Tue, 14 May 2013 00:32:49 -0400, Timothee Cour <thelastmammoth@gmail.com> wrote: >> I declared fun(T) as fun(T)() with the added parenthesis, and it >> worked (tested on dmd 2.062 / ubuntu 64bits). > > sorry I reduced wrongly. > Here's the inconsistency: > > ---- > struct A { > this(T)(T x) { } > } > auto fun1(){ > auto a=A.__ctor!(int)(1); //OK This line causes an error message for me: testctor.d(5): Error: need 'this' for 'this' of type 'pure nothrow ref @safe A(int x)' > return a; > } > auto fun2(){ > // return A.__ctor!(int)(1); //uncomment gives Error: type A is not an > expression Same error for me here: testctor.d(9): Error: need 'this' for 'this' of type 'pure nothrow ref @safe A(int x)' I'm using dmd beta candidate, 2.061 does give the same error message you have. Note that you may expect this as you are using an undocumented "feature" :) -Steve |
Copyright © 1999-2021 by the D Language Foundation