this(this) / opAssign

David Nadlinger see at klickverbot.at
Thu Jan 10 15:56:09 PST 2013


On Thursday, 10 January 2013 at 23:37:14 UTC, Namespace wrote:
> Without a declared opAssign, this
>
>   S s3;
>   s3 = s1;
>
> also calls the postblit. That is strange.

Think of it like this: Blit means bit-by-bit copy, so a postblit 
is a function that is invoked on the result of every bit-by-bit 
copy operation. The default behavior for struct assignment is 
precisely to copy over the contents, so it makes sense for the 
postblit to be invoked in that case.

David


More information about the Digitalmars-d-learn mailing list