[Issue 3694] New: Template this parameters don't work with operator overloads

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 10 15:07:38 PST 2010


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

           Summary: Template this parameters don't work with operator
                    overloads
           Product: D
           Version: 2.036
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: tomeksowi at gmail.com


--- Comment #0 from Tomasz Sowiński <tomeksowi at gmail.com> 2010-01-10 15:07:37 PST ---
Testcase:

class A {
    int a;
    This opAssign(this This)(int a) {
        this.a = a;
        return this;
    }
}

void main() {
    A aa = new A;
    aa = 4;   // oops!
}

Error: template test.A.opAssign(this This) does not match any function template
declaration
Error: template test.A.opAssign(this This) cannot deduce template function from
argument types !()(int)

-----------------------------------------------

The testcase should compile. Problem is that when operator overloads are used,
template this parameters are not inferred. I suspect it's like that for all
operator overloads (I tested only for assign and add, though).

When you call the operator functions explicitly, aa.opAssign(4), it compiles.

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