D issues are now
tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Summary: |
Cannot alias a tuple member which is a template instance |
Product: |
D
|
Reporter: |
Max Samukha <samukha> |
Component: |
dmd | Assignee: |
Walter Bright <bugzilla> |
Status: |
RESOLVED
FIXED
|
Severity: |
blocker
|
Priority: |
P2
|
Version: |
D1 (retired) |
Hardware: |
x86 |
OS: |
Windows |
----
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
Max Samukha
2008年05月10日 03:01:30 UTC
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()
{
}
----
Comment 2
Walter Bright
2008年05月22日 05:06:41 UTC
Fixed dmd 1.030 and 2.014