this(this) / opAssign

Namespace rswhite4 at googlemail.com
Fri Jan 11 01:21:40 PST 2013


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. ;)


More information about the Digitalmars-d-learn mailing list