ref barfs template parameter deduction?
NaN
divide at by.zero
Fri May 8 22:03:47 UTC 2020
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
More information about the Digitalmars-d-learn
mailing list