Build opAssign for struct.
ref S opAssign(S s) { ... }
Note that s will be constructed onto the stack, and probably
copy-constructed in caller site.
If S has copy copy construction and/or destructor,
the body will make bit-wise object swap:
S __swap = this; // bit copy
this = s; // bit copy
__swap.dtor();
Instead of running the destructor on s, run it on tmp instead.
Otherwise, the body will make member-wise assignments:
Then, the body is:
this.field1 = s.field1;
this.field2 = s.field2;
...;
Build opAssign for struct. ref S opAssign(S s) { ... }
Note that s will be constructed onto the stack, and probably copy-constructed in caller site.
If S has copy copy construction and/or destructor, the body will make bit-wise object swap: S __swap = this; // bit copy this = s; // bit copy __swap.dtor(); Instead of running the destructor on s, run it on tmp instead.
Otherwise, the body will make member-wise assignments: Then, the body is: this.field1 = s.field1; this.field2 = s.field2; ...;