[Issue 4749] New: Templated & non-templated constructors conflicting

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 28 21:52:51 PDT 2010


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

           Summary: Templated & non-templated constructors conflicting
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: mitch.hayenga at gmail.com


--- Comment #0 from Mitch Hayenga <mitch.hayenga at gmail.com> 2010-08-28 21:52:39 PDT ---
I don't have a D compiler on me at the moment, but this came up earlier today. 
Heres a simplified case.

// This breaks due to the constructors (template error message from DMD)
struct A {
  Variant v;
  string s;

  this(T)(T val, string str) {
    v = Variant(val);
    str = s;
  } 

  this(int val) {
    v = val;
  }
}

// This works
struct A {
  Variant v;
  string s;

  this(T)(T val, string str) {
    v = Variant(val);
    str = s;
  } 

  this(T)(int val) {  // Useless template parameter
    v = val;
  }
}

-- 
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