Boost logo

Boost :

From: Brian McNamara (lorgon_at_[hidden])
Date: 2003-10-30 12:52:57


On Wed, Oct 29, 2003 at 02:05:14PM -1000, David Abrahams wrote:
> Brian McNamara <lorgon_at_[hidden]> writes:
> > I've come to think of assignment as
> > T tmp( data );
> > this->swap( tmp ); // nothrow
> > // tmp.~T()
>
> This is a misconception. In many cases (see vector assignment)
> producing the strong guarantee induces unavoidable overhead for a
> "benefit" that the client may not need at all (e.g. the vector was on
> the stack and will be destroyed anyway). Since the strong guarantee
> is generally easy to add at an outer layer when needed as long as
> there's a nothrow swap, the "don't pay for what you don't use"
> principle dictates that copy/swap should never be used inside an
> assignment operator to get it.

I see. Thanks for this refresher; I re-read some of the stuff you and
Herb Sutter have written on the topic and think my mind is now back on
track. :)

-- 
-Brian McNamara (lorgon_at_[hidden])

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