Bug 2090 – Cannot alias a tuple member which is a template instance
Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2008-05-09T17:16:00Z
Last change time
2014-02-24T15:33:15Z
Assigned to
bugzilla
Creator
samukha
Comments
Comment #0 by samukha — 2008-05-09T17:16:45Z
----
template Tuple(A...)
{
alias A Tuple;
}
template Bar()
{
const s = "a bar";
}
alias Tuple!(Bar!()) tuple;
const i = 0;
alias tuple[i] bar; // 'alias tuple[0] bar;' works
static assert(bar.s == "a bar");
----
Error: tuple[0] is not a type
Comment #1 by samukha — 2008-05-10T03:01:30Z
It may be not a blocker as a workaround exists:
----
template Tuple(A...)
{
alias A Tuple;
}
template Bar()
{
const s = "a bar";
}
char[] toString(size_t v)
{
char[] s;
s ~= " ";
size_t i = 1;
do
{
s[s.length - i] = '0' + v % 10;
i++;
v /= 10;
} while (v)
return s[$ - i + 1..$];
}
alias Tuple!(void, Bar!()) tuple;
const i = 1;
mixin ("alias tuple[" ~ toString(i) ~ "] bar;");
static assert(bar.s == "a bar");
void main()
{
}
----