Why are template alias parameters broken?

Menshikov mensikovk817 at gmail.com
Fri Aug 27 18:47:56 UTC 2021


It's work:

```d
template Foo(alias var)
{
     void inc() { var++; }
}

void main()
{
     int v = 4;
     alias foo = Foo!(v);
     foo.inc();
     assert(v == 5);
}
```
But it doesn't work:
```d
template Foo(alias var)
{
     void inc() { var++; }
}

void main()
{
     struct V{
       int a;
     }
     auto v = V(4);
     alias foo = Foo!(v.a);
     foo.inc();//err
     assert(v.a == 5);
}
```
Hence this applies to Alias!() and AliasSeq!()


More information about the Digitalmars-d mailing list