Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2002-02-05 11:57:17


On Tuesday, February 5, 2002, at 11:38 AM, Peter Dimov wrote:

> 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.

Yup! A minimum of 2 types of move are absolutely necessary:

1. Move construct.
2. Move assign.

One could argue that 2 more moves are useful:

3. Move construct, destructing the source.
4. Move assign, destructing the source.

However 3 and 4 are very easily built on 1 and 2 by just calling the
destructor on the source after the move.

This again is just like copy:

1. Copy constructor.
2. Assignment operator.

And destruction of the source is a separate and optional additional step.

As Peter says, without move construct, move semantics will not be
valuable to vector (or deque, or any other array-like container).

-Howard


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