how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}
Steven Schveighoffer
schveiguy at yahoo.com
Tue May 14 09:50:12 PDT 2013
On Tue, 14 May 2013 00:32:49 -0400, Timothee Cour
<thelastmammoth at 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
More information about the Digitalmars-d-learn
mailing list