opIndex for type list

data pulverizer data.pulverizer at gmail.com
Mon Aug 24 14:19:14 UTC 2020


Hi all,

I am trying to implement `opIndex` (e.g. T[i]) for types in a 
struct. So for I have `length`:

```d
struct TList(T...)
{
   enum long length = T.length;
}
```

and have tried including

```d
alias opIndex(long i) = T[i];
```

or

```d
alias opIndex(alias i) = T[i];
```

called with

```d
alias tList = AliasSeq!(bool, string, ubyte, short, ushort);
TList!(tList)[0];
```

but that doesn't work and I get the error:

```d
opIndex cannot deduce function from argument types !()(int), 
candidates are:
opIndex(long i)

```




More information about the Digitalmars-d-learn mailing list