[Issue 9665] Structure constant members can not be initialized if have opAssign

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 10 07:08:04 PDT 2013


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



--- Comment #20 from Max Samukha <samukha at voliacable.com> 2013-10-10 07:07:59 PDT ---
I see there was a discussion in bug 9665. Kenji, if you are fixing this, please
don't forget about postblit, which is a constructor and should have similar
semantics. That is:

struct S {
    @disable this();

    this(int x) {        
    }

    static int postblit;
    this(this) {
        postblit = true;
    }

    static int assigned;
    void opAssign(S s) {
        assigned = true;
    }
}

class A {
    S s;

    this() {
        auto s1 = S(1);
        s = s1;
        assert(!S.assigned);
        assert(S.postblit);
    }
}

void main() {
    auto a = new A;     
}


Copy-construction should be performed, not assignment.

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