On Thursday, 23 November 2017 at 15:26:03 UTC, Timoses wrote:
    A member;

    this(A a)
    {
this.member = a; // specifically aiming towards this assignment...


That's not assignment, that's construction.

opAssign is only called when you assign over a struct object that already exists. If there isn't an existing object in the variable already, it instead calls a constructor.

A a = A(); // construction, there is no existing a to call
A a; // construction done here...
a = x; // so this is now assignment over the existing object


Sometimes, they look the same, as in your case, but since you are assigning a member for the first time inside a constructor, it still counts as construction of the child object instead of assignment over an existing object.

Reply via email to