Very fortunately auto ref
prevents overloading. After a post on HN that get very little interest0 I've found that the D language is able to monomorphize a function template in a way that's very unexpected, or at least unspecified:
auto ref T max(T)(auto ref T u, auto ref T v) => u > v ? u : v;
void main()
{
int a = 1;
int b = 0;
int x;
// lvalue version
assert(&max(a,b) is &a);
// rvalue version
assert(max(a,0) == a);
}
so at some point you have to imagine me trying this code, because "it's not sure if that will work".
Not very interesting you would say. Indeed when a problem is resolved you just dont even think it can exist.