Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-02-05 11:38:03


From: "Beman Dawes" <bdawes_at_[hidden]>
> At 07:37 PM 2/4/2002, Jon Kalb wrote:
> >What I am saying is that I think swap semantics accomplish what you want
> >to accomplish with move, but is "more fundamental." Herb Sutter has
> >convinced me that if I want to write exception safe code, I need to
> >create a swap operation anyway and if I could use that operation to
> >accomplish what you want to accomplish with move, I think it's a win.
>
> I assume Jon's reference to Herb Sutter is to Herb's "Exceptional C++"
> (Addison Wesley) which I was just reading the other day. While reading
> items 8 through 19, I kept wondering if some of the uses of swap Herb is
> advocating wouldn't better be served by move. While swap would always
> work, move might generate less code in the cases where it was
> applicable. But I haven't done the analysis, so don't have an opinion
> yet. I think there is a (swap vs move) rule-of-thumb hiding there, but
I'm
> not smart enough to identify it without a lot more study.

And let's not forget the 'other' move, that moves an object into
uninitialized memory (move1 and swap both require two objects to operate
on.) std::vector needs this while reallocating.


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