On Saturday, 21 June 2014 at 20:03:26 UTC, Ali Çehreli wrote:
> Now, http://dlang.org/struct.html#AssignOverload says:
>
> ref S opAssign(S s)
> {
Note that opAssign takes by-value. The post-blits that you see
are due that copy. i.e. b in main is copied to the argument
that opAssign
On 06/21/2014 11:56 AM, "Marc Schütz" " wrote:
> import std.stdio;
>
> struct A {
> this(this) {
> writeln("A.this(this)");
> }
>
> B b1, b2;
> }
>
> struct B {
> this(this) {
> writeln("B.this(this)");
> }
import std.stdio;
struct A {
this(this) {
writeln("A.this(this)");
}
B b1, b2;
}
struct B {
this(this) {
writeln("B.this(this)");
}
}
void main() {
A a, b;
a = b;
}
This outputs:
B