Function Template Overloading
Q. Schroll via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 14 19:29:42 PDT 2017
void test(T)(T* arg);
void test(T)(ref T arg);
Let p be any pointer. Why is test(p) not an ambiguity error? Why
is the second overload chosen?
Making the first one take auto ref T* lets the compiler choose
the first.
Making the second one non-ref lets the compiler give me an
ambiguity error.
Template Functions are not mentioned in the spec, at least not on
https://dlang.org/spec/function.html#function-overloading, but it
suggests that ref should not make the decision if it can be bound
to.
More information about the Digitalmars-d-learn
mailing list