Comment #0 by qs.il.paperinik — 2024-06-16T11:37:50Z
```d
void f(T)(auto ref T x) {}
void main()
{
int x;
f!long(x); // Error: template `f` is not callable using argument types `!(long)(int)`
}
```
This should instantiate `f` as `f!long(long x)`, as `int` converts to `long` and `cast(long)x` is an rvalue.
I don’t know how far with implicit conversions this should go, but it should work for built-in integer and floating-point types. It should also work for class/interface types with inheritance relationship, and while binding those by `auto ref` is weird to do explicitly, such a binding might end up from templates that bind arbitrary type objects that happen to be class handles in the user’s code. Then:
```d
Exception e = new Exception("");
f!Object(e); // Currently error, should be pass-by-value
```
With my proposed fix for Issue 24611, users could opt-into `ref` explicitly if they need to.
Comment #1 by robert.schadek — 2024-12-13T19:35:45Z