D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6474 - aliasing type tuple elements' members is onerous
Summary: aliasing type tuple elements' members is onerous
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
: 5697 6740 (view as issue list)
Depends on:
Blocks:
 
Reported: 2011-08-11 19:32 UTC by Ellery Newcomer
Modified: 2020-06-13 17:07 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ellery Newcomer 2011-08-11 19:32:04 UTC
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 Andrej Mitrovic 2013-02-08 15:28:59 UTC
*** Issue 5697 has been marked as a duplicate of this issue. ***
Comment 2 Andrej Mitrovic 2013-02-10 09:10:37 UTC
*** Issue 6740 has been marked as a duplicate of this issue. ***
Comment 3 Andrej Mitrovic 2013-03-31 13:36:42 UTC
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 Meta 2014-05-30 00:12:23 UTC
I have just run into this. Has it been fixed in the newest DMD release?
Comment 5 basile-z 2020-06-13 17:07:38 UTC
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))
---