Bug 6474 – aliasing type tuple elements' members is onerous
Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-08-11T19:32:04Z
Last change time
2020-06-13T17:07:38Z
Assigned to
No Owner
Creator
Ellery Newcomer
Comments
Comment #0 by ellery-newcomer — 2011-08-11T19:32:04Z
code like
struct X(T){
alias T TT;
}
alias TypeTuple!(int,int, X!string) G;
alias G[2].TT TT; // <-- parse failure
doesn't work. It's just not built in to the D grammar.
Of course, the workaround is simply
alias G[2] G2;
alias G2.TT TT;
Comment #1 by andrej.mitrovich — 2013-02-08T15:28:59Z
*** Issue 5697 has been marked as a duplicate of this issue. ***
Comment #2 by andrej.mitrovich — 2013-02-10T09:10:37Z
*** Issue 6740 has been marked as a duplicate of this issue. ***
Comment #3 by andrej.mitrovich — 2013-03-31T13:36:42Z
Just pasting this here as I've ran into it again:
template test(T, Preds...)
{
enum bool test = Preds[0]!T; // error: semicolon expected, not '!'
}
A workaround is to use an alias:
template test(T, Preds...)
{
alias Pred = Preds[0];
enum bool test = Pred!T;
}
Comment #4 by monkeyworks12 — 2014-05-30T00:12:23Z
I have just run into this. Has it been fixed in the newest DMD release?
Comment #5 by b2.temp — 2020-06-13T17:07:38Z
supported since 2.068.2.
---
import std.meta : AliasSeq;
struct X(T)
{
alias T TT;
}
alias G = AliasSeq!(int,int, X!string);
alias TT = G[2].TT;
static assert (is(TT == string))
---