Why are template alias parameters broken?

Steven Schveighoffer schveiguy at gmail.com
Fri Aug 27 19:32:49 UTC 2021


On 8/27/21 3:14 PM, Steven Schveighoffer wrote:

> To work around, you can do:
> 
> ```d
> template Foo(alias var)
> {
>     void inc() {var.a++}
> }
> ```
> 
> and then pass `v` instead of `v.a`.

Another possible workaround:

```d
auto v = V(4);
ref int a() { return v.a; }
alias foo = Foo!a;
foo.inc();
```

-Steve


More information about the Digitalmars-d mailing list