[Issue 7032] New: OpAssign is not called when this(this) is disabled

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 29 13:17:23 PST 2011


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

           Summary: OpAssign is not called when this(this) is disabled
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: deadalnix at gmail.com


--- Comment #0 from deadalnix <deadalnix at gmail.com> 2011-11-29 13:16:21 PST ---
As of
http://digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=150299

If we disable this(this) in a struct, the opAssign member function should be
used if it exists. Here is a sample code :

module fail2;

struct Fail {
    @disable
    this(this);

    ref Fail opAssign(ref const Fail t) {
        return this;
    }
}

int main(string[] argv) {
    Fail a;
    Fail b = a; // Error: struct fail2.Fail is not copyable because it is
annotated with @disable

    return 0;
}

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