Bug 5697 – Instantiation from typetuple of templates

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-03-04T09:50:00Z
Last change time
2013-02-08T15:28:59Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-03-04T09:50:53Z
This D2 code compiles and runs with no errors (DMD 2.052): template TypeTuple(TList...) { alias TList TypeTuple; } int foo(alias bar)() { return bar(); } int spam() { return 1; } void main() { alias TypeTuple!(foo, foo) templates; alias templates[0] templates0; // OK assert(templates0!spam() == 1); // OK } But if I remove the alias, to merge the last two lines: template TypeTuple(TList...) { alias TList TypeTuple; } int foo(alias bar)() { return bar(); } int spam() { return 1; } void main() { alias TypeTuple!(foo, foo) templates; assert(templates[0]!spam() == 1); // line 12, error } It doesn't compile, with the errors: test.d(12): found '!' when expecting ')' test.d(12): found 'spam' when expecting ';' following statement test.d(12): expression expected, not ')' Some alternative ways to write this line don't seem to work: templates[0]!spam()
Comment #1 by andrej.mitrovich — 2013-02-08T15:28:59Z
*** This issue has been marked as a duplicate of issue 6474 ***