July 15, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3177

           Summary: constrained template reverse operator overload
                    prohibits use of non-reverse overloads
           Product: D
           Version: 2.031
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: kamm-removethis@incasoftware.de


struct imaginary {}

struct complex {
    complex opAdd(complex s) { return this; }
    complex opAdd_r(T)(T t) if (is(T == imaginary)) { return this; }
}

void main() {
    complex s;
    s = s + s;
}

yields the error

Error: template complex.opAdd_r(T) if (is(T == imaginary)) does not match any
function template declaration
Error: template complex.opAdd_r(T) if (is(T == imaginary)) cannot deduce
template function from argument types !()(complex)

even though opAdd_r is only defined for T == imaginary.

This may be by design: calling a constrained template function with template arguments that don't satisfy the constraints also doesn't give you an "undefined identifier" error, but rather a message like the one above, mentioning the function template declaration. However, it makes using constrained templates for operator overloading impossible.

I'd expect a non-matching template operator overload to be ignored if there are other matches.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3177


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich@gmail.com
         Resolution|                            |FIXED


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-01-21 18:01:32 PST ---
Can't reproduce in 2.057, likely fixed by now.

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