
on Mon Jan 05 2009, "Daniel James" <daniel_james-AT-fmail.co.uk> wrote:
2009/1/4 Ion GaztaƱaga <igaztanaga@gmail.com>:
Howard's unique_ptr contribution has shown again the need for a unified move emulation in Boost. We already have move emulation at least in 5 libraries:
In the move library I was working on, I wasn't aiming for unified move emulation, instead it's meant to be flexible enough to support different move implementations. This would still be important when using libraries outside of boost, as they can't be expected to use our implementation.
-> Unordered: based on Adobe's move library. It's more advanced than the previous one, but Adobe's own library says (http://stlab.adobe.com/group__move__related.html) that a Movable type must satisfy the requirements of concept Regular, which has copy constructor (thus disabling move-only types!). I don't know if the move emulation itself uses Regular requirements.
Move only types are possible (see the attached example, it uses the library at http://svn.boost.org/svn/boost/sandbox/move, although I haven't updated the documentation yet. it's a similar technique to thread's). There is a problem - it doesn't support taking a const reference to a returned noncopyable type. I think your unique_ptr deals with this case correctly, but it is more complicated to implement. If it could be made easy that would be ideal.
I'm probably not going to have any time to work on this in the near future, as I've got a few website and documentation tasks to do before the next release. I naively assumed that all I'd need to do was boostify the adobe library, but it ended up being a larger task. So if you want to take it on or do something different feel free.
Aside from contributions I've made to the Adobe move library, I also did a bunch of additional work/thinking about this topic, and some collaboration with Daniel on it. I have some things that are worth including, like: assign(x) = expr that moves from expr if it is a movable rvalue and otherwise swaps if it is a swappable rvalue. Also I figured out how to build "perfect" moving binary operations in C++03 (e.g. string+string), where there are no ambiguities and it will always move if at least one argument is an rvalue. I can send what code I have if you want it. -- Dave Abrahams BoostPro Computing http://www.boostpro.com