Brainstorming: Explicit instantiation of function template with `auto ref` parameters
Basile B.
b2.temp at gmx.com
Fri Feb 21 11:27:26 UTC 2025
On Thursday, 20 February 2025 at 23:24:10 UTC, Quirin Schroll
wrote:
> [...]
> One way I thought could work is just passing ref T:
> example!(ref long), but that doesn’t work for the int parameter.
maybe a way to go further with this idea is not to forget that we
know the name of the `int` parameter, so something like
```d
void example(Ts...)(auto ref int arg, auto ref Ts args) { }
// void function(ref int arg);
auto fp1 = &example!(ref int arg);
// void function(ref int, char, ref wchar);
auto fp2 = &example!(ref int arg, char, ref wchar);
```
looks possible even if that only works if the parameter name is
specified.
But otherwise the other syntax, I mean the one you've explained
more, would work I think. That looks a bit like if the
instantiation is for an array literal but it can be distinguished
with two lookups (unless I'm loosing my D, an expression cannot
start with `auto` or `ref` ?), or otherwise three (once reached a
comma or a closing squared bracket).
More information about the Digitalmars-d
mailing list