Does opAssign still work the way I quote from http://digitalmars.com/d/2.0/struct.html:

<quote>
S* opAssign(S s)
{   ... bitcopy *this into tmp ...
    ... bitcopy s into *this ...
    ... call destructor on tmp ...
    return this;
}
</quote>

The reason for the temporary must be exception safety. Otherwise, one would simply destroy *this and then copy from s. Am I correct?

Additionally, I suspect that the 'bitcopy's above are actually memberwise copies, calling each member's post-blit function. If so, then a member's post-blit may throw and the above code is not exception-safe anymore.

Is the documentation old, and opAssign is in fact exception-safe? If it was never intended to be, then why the temporary?

Thank you,
Ali

Reply via email to