Ok given the following code...

auto foo(T)(T x)
{
    struct V1 { T* what; }
    V1 v;
    return v;
}

auto bam(T)(T x)
{
    struct V2 { T* what; }
    V2 v;
    return v;
}

void bar()
{
    bam(foo(1));
}


if you change the declaration of foo or bam to "ref T x", ie..

auto foo(T)(ref T x)
auto bam(T)(ref T x)

then the compiler complains thus...

ldc 1.17.0 (Editor #1, Compiler #1) D#1 with ldc 1.17.0
<source>(23): Error: template `test.foo` cannot deduce function from argument types `!()(int)`, candidates are:

<source>(7):        `test.foo(T)(ref T x)`

Compiler returned: 1

Why would ref make any difference to deciding what function to use, it even says there's only one candidate?

Cheers

Reply via email to