[Issue 3530] New: A case where IFTI works with int but not enum

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 20 03:09:48 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3530

           Summary: A case where IFTI works with int but not enum
           Product: D
           Version: 2.036
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bugzilla at kyllingen.net


--- Comment #0 from Lars T. Kyllingstad <bugzilla at kyllingen.net> 2009-11-20 03:09:45 PST ---
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))

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list