Bug 2725 – Pattern matching in static if not working with variadic arguments
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2009-03-10T10:11:00Z
Last change time
2015-06-09T01:31:18Z
Assigned to
bugzilla
Creator
andrei
Comments
Comment #0 by andrei — 2009-03-10T10:11:26Z
struct A(B...) {}
void main()
{
alias A!(int, float) X;
static if (!is(X Y == A!(Z), Z))
{
static assert(false);
}
}
This example fails the static assert. If one removes the float in the instantiation of A the example compiles.
The compiler should match Z to the type tuple (int, float). Otherwise it is impossible to detect whether a type is an instantiation of a variadic template.
Comment #1 by bugzilla — 2009-03-13T16:40:31Z
The is expression needs to be written as:
static if (!is(X Y == A!(Z), Z...))
with the addition of the ... to indicate that Z is a tuple parameter. It still won't compile right, though, so I'll fix it.