On 10/15/2018 01:36 PM, Márcio Martins wrote:

> Considering that the declaration is legal, and that the template
> parameter deduction works when Args.length == 0, but stops working when
> Args.length > 0.

For deduction to work, there must be function arguments. So, just add Args to the function parameter list and all works:

import std.stdio;

void incx(T, Args...)(ref T t, Args) {  // <-- Added Args
    ++t.x;
}

static struct Test(T) {
    T x;
}

void main() {
    Test!uint t;
    t.incx();
    t.incx!();
    incx(t);
    t.incx(1, 2, 3);           // <-- Removed '!'
    incx(t, 1, 2, 3);
    writeln(t.x);
}

Ali

Reply via email to