January 11, 2013 Re: this(this) / opAssign | ||||
---|---|---|---|---|
| ||||
Posted in reply to monarch_dodra | On Thursday, 10 January 2013 at 23:49:40 UTC, monarch_dodra wrote:
> 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.
>
> If there is no user declared opAssign, then opAssign is implemented in terms of postblit. It's designed that way.
>
> This is kind of like C++'s copy and swap idiom, but built into the language.
And that was what I did not know and could not find anywhere. So it is enough if I declare a postblit.
And yes, benchmarks are hard. ;)
|
Copyright © 1999-2021 by the D Language Foundation