Boost logo

Boost :

Subject: Re: [boost] [proposal] raw move (was: [interest] underlying type library)
From: Julian Gonggrijp (j.gonggrijp_at_[hidden])
Date: 2011-08-23 09:44:31


Christopher Jefferson wrote:

> Can you first of all give a good example (with source) of where using move_raw would out-perform move assignment / constructors from C++0x, particularly in any standard library function (random_shuffle has a fairly small implementation for example). I don't really see how it will help that much.

There is a very simple reason why move_raw will outperform move
assignment for any non-POD type:

move assignment = move_raw + fixing up the source object ,

where 'fixing up the source object' is a cheap default constructor in
the best case. In that case move_raw is likely to be cheap as well,
which means that move assignment takes about twice as much work as
move_raw.

Since the implementation of an algorithm with move_raw contains
exactly the same steps as when it is implemented with move assigment,
except that all move assignments are replaced by raw moves, the
implementation with raw moves will always perform strictly fewer
operations than the move assignment-based implementation for non-POD
types.

An excellent explanation is provided by Alexander Stepanov:
http://www.stepanovpapers.com/notes.pdf (lectures 4 and 5).

For some historical background you may also want to refer to the
'mother thread' of my proposal ('[interest] underlying type library'),
in which the efficiency benefits of move_raw have already been
discussed. The following post is of particular interest:

http://lists.boost.org/Archives/boost/2011/08/184933.php

The entire thread starts here (though I don't recommend reading all of
it):

http://lists.boost.org/Archives/boost/2011/08/184872.php

(note that the bitwise approach has been abandoned in the current
proposal).

HTH, Julian


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