.tupleof solving generates a tuple for each use, so aliasing, without using an AliasSeq, should work
---
struct F
{
alias thisTup = typeof(this).tupleof;
int a,b,c,d;
void test()
{
static foreach (i; 0 .. 4)
thisTup[i] = i + 1;
assert(a == 1);
assert(b == 2);
assert(c == 3);
assert(d == 4);
}
}
void main()
{
F().test();
}
---
Comment #1 by dlang-bot — 2020-08-22T01:58:02Z
@NilsLankila created dlang/dmd pull request #11604 "fix issue 21187 - allow to alias directly `.tupleof`" fixing this issue:
- fix issue 21187 - allow to alias directly `.tupleof`
It is actually not a good idea to use `.tupleof[index]` because the whole tuple is regenerated for each use.
But for now `alias id = T.tupleof` is not allowed which is odd.
https://github.com/dlang/dmd/pull/11604
Comment #2 by robert.schadek — 2024-12-13T19:11:12Z