|
Boost : |
Subject: Re: [boost] [move][container] Review Request (new versions of Boost.Move and Boost.Container in sandbox and vault)
From: Christopher Jefferson (chris_at_[hidden])
Date: 2009-10-17 04:39:26
On 16 Oct 2009, at 02:10, Thomas Klimpel wrote:
>
> So I'm left with the impression that there might be quite some good
> reasons not to implement move-assignment as swap, but no really
> conclusive counter examples against it. On the other hand, as long
> as the absence of conclusive counter examples can't be "proved",
> ruling that move-assignment may generally be implemented as swap
> will be risky or worse.
Just as one point of information, which I've previously seen used in
favour of using swap as move.
While it is true that a move which doesn't swap on (for example)
vector<T> is O(n) rather than O(1), due to the need to destruct all
the elements, I found in experiments that sorting a range of vector<T>
is actually very slightly faster when move-assignment is NOT
implemented as swap, so performance isn't even really an argument in
it's favour.
Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk