Boost logo

Boost :

Subject: Re: [boost] Improving the assignment operators of various Boost types
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2008-09-10 14:22:26


Andrey Semashev wrote:
> One downside is that self-assignment is made suboptimal. My typical
> operator= implementation is:
>
> T& operator= (T const& that)
> {
> if (this != &that)
> T(that).swap(*this);
> return *this;
> }
>
> Not sure, however, if it is critical enough.

In practice I haven't written any interesting code that does self
assignment. Perhaps you have. In my code I'd consider this a pessimization.

Thanks,

Michael Marcin


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk