opAssign for most struct assignment calls not executed
Timoses
timosesu at gmail.com
Thu Nov 23 16:02:02 UTC 2017
On Thursday, 23 November 2017 at 15:45:17 UTC, Rene Zwanenburg
wrote:
> On Thursday, 23 November 2017 at 15:26:03 UTC, Timoses wrote:
>> A aaa = a;
>
> That's initialization, not assignment, which is subtly
> different. It will call the postblit on aaa instead of
> opAssign. A postblit can be defined this way:
>
> this(this)
> {
>
> }
>
> There is no way to access the original a from the postblit. All
> fields have already been copied, you can use it to duplicate
> reference types, increment reference counts, and other things
> like that.
Wow, that's great! Thanks for the clarification you two!
For reference:
https://dlang.org/spec/struct.html#struct-postblit
http://ddili.org/ders/d.en/special_functions.html
More information about the Digitalmars-d-learn
mailing list