Bug 3530 – A case where IFTI works with int but not enum

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2009-11-20T03:09:00Z
Last change time
2015-06-09T01:27:03Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bugzilla

Comments

Comment #0 by bugzilla — 2009-11-20T03:09:45Z
This is probably a corner case, but it's one where IFTI works perfectly for ordinary int template parameters, but not for named int enums (which should more or less be the same thing): // This compiles: struct Foo(T, int I) { } void useFoo(T, int I)(Foo!(T, I) a, Foo!(T, 2) b) { } void main() { Foo!(double, 0) foo0; Foo!(double, 2) foo2; useFoo(foo0, foo2); // This calls useFoo!(double, 0). Yay! } // Replace int with an enum and it no longer compiles: enum MyEnum { X, Y } struct Bar(T, MyEnum E) { } void useBar(T, MyEnum E)(Bar!(T, E) a, Bar!(T, MyEnum.Y) b) { } void main() { Bar!(double, MyEnum.X) barX; Bar!(double, MyEnum.Y) barY; useBar(barX, barY); // Should call useBar!(double, MyEnum.X), // instead it gives the errors below. } Error: template c.useBar(T,MyEnum E) does not match any function template declaration Error: template c.useBar(T,MyEnum E) cannot deduce template function from argument types !()(Bar!(double,cast(MyEnum)0),Bar!(double,cast(MyEnum)1))
Comment #1 by verylonglogin.reg — 2012-11-04T22:35:36Z
It looks fixed now.