Boost logo

Boost :

From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2003-08-30 15:00:04


From: "Hamish Mackenzie" <hamish_at_[hidden]>

> Also "swap" is often the fastest way to move an non POD. I spent some
> time writing something similar to what you describe...
>
> http://groups.yahoo.com/group/boost/files/move.tar.gz
>
> The idea is that you have four ways to move an object depending on
> whether you need to construct the destination or destroy the source.
>
> move_to( destination ) = move_from( source );
> move_to_construct( destination ) = move_from( source );
> move_to_construct( destination ) = move_from_destroy( source )
> move_to( destination ) = move_from_destroy( source )
>
> I started trying to expand on this to work with moving blocks. I am
> afraid I didn't get very far before more pressing matters came up. I'll
> see if I can find any more of the code.
>
IMO move* and memcpy_moveable<> have little different goals.

To move array of objects (like in resized vector<> or circular_buffer<>)
memcpy() should have clear speed advantage to whatever else and that's why I
am proposing it. (It may get useful when moving big (say >= 32B) single
object instance.)

I quite like the library - it allows to fiddle with optimisation without
intrusive changes in design, right? One trick it may also employ is to
overwrite (in debug mode) destroyed object with some debugger friendly bit
pattern.

Maybe memcpy_moveable<> way can be added into move* library, as 4th method.
And/or move library may be extended to handle moves of arrays.

/Pavel


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