Is this a bug?

Steven Schveighoffer schveiguy at gmail.com
Mon Oct 15 16:46:34 UTC 2018


On 10/15/18 12:40 PM, Márcio Martins wrote:
> import std.stdio;
> 
> void incx(T, Args...)(ref T t) {
>      ++t.x;
> }
> 
> static struct Test(T) {
>      T x;
> }
> 
> void main() {
>      Test!uint t;
>      t.incx();           // works
>      t.incx!();          // works
>      incx(t);            // works
>      t.incx!(1, 2, 3);   // what?
>      incx(t, 1, 2, 3);   // what?
>      writeln(t.x);
> }
> 
> 
> test.d(16): Error: template test.incx cannot deduce function from 
> argument types !(1, 2, 3)(Test!uint), candidates are:
> test.d(3):        test.incx(T, Args...)(ref T t)

No, not a bug.

I suspect you want this?

void incx(Args..., T)(ref T t);

> test.d(17): Error: template test.incx cannot deduce function from 
> argument types !()(Test!uint, int, int, int), candidates are:
> test.d(3):        test.incx(T, Args...)(ref T t)
> Failed: ["/usr/bin/dmd", "-v", "-o-", "test.d", "-I."]
> 

Did you mean incx!(T, 1, 2, 3)(t) ?

Or with the updated incx I suggested:
incx!(1, 2, 3)(t)

-Steve


More information about the Digitalmars-d-learn mailing list