[Issue 5856] New: overloading on const doesn't work for operator overload

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 18 13:45:36 PDT 2011


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

           Summary: overloading on const doesn't work for operator
                    overload
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2011-04-18 13:42:03 PDT ---
import std.stdio;
struct X
{
    void f()       { writeln("X.f mutable"); }
    void f() const { writeln("X.f const"); }

    void g()()       { writeln("X.g mutable"); }
    void g()() const { writeln("X.g const"); }

    void opOpAssign(string op)(int n)       { writeln("X+= mutable"); }
    void opOpAssign(string op)(int n) const { writeln("X+= const"); }
}
void main()
{
    X xm;
    xm.f();     // prints "X.f mutable"
    xm.g();     // prints "X.g mutable"
    xm += 10;   // should print "X+= mutable" (1)

    const(X) xc;
    xc.f();     // prints "X.f const"
    xc.g();     // prints "X.g const"
    xc += 10;   // should print "X+= const" (2)
}

Compiling this code occurs ambiguous error on line (1) and (2). 
I think issue 3810 is related.

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