[sandbox][move] Regular requirement

I'm using the current move library in the sanbox by daniel james (which I believe is the 4th move emulation library I've used now). It seems to be very good so far and makes writing code that handles both move and copy a breeze. I hope this gets finalized and ready for review soon because a consistently used move emulation library would be a great aid to writing efficient libraries that work well together. However the documentation says that objects have to model the Regular concept in order to model the Movable concept. This seems unfortunate as Regular puts a lot of requirements on types that don't seem necessary to gain moving. It requires Assignable which requires a copy constructor and it requires EqualityComparable which seems unnecessary. As a matter of fact I'm currently using the library with types I derive from boost::noncopyable on msvc 2008 and it is working wonderfully. Can the Movable concept be relaxed to require only what is truly necessary? Thanks, Michael Marcin

2008/7/31 Michael Marcin <mike.marcin@gmail.com>:
I'm using the current move library in the sanbox by daniel james (which I believe is the 4th move emulation library I've used now). It seems to be very good so far and makes writing code that handles both move and copy a breeze. I hope this gets finalized and ready for review soon because a consistently used move emulation library would be a great aid to writing efficient libraries that work well together.
I'm pleased (and slightly surprised) that it's already getting use. To give credit where it's due, most of it is based on work by Adobe and David Abrahams. I also took some code from the move emulation in the thread library and the old move library. Tracing the complete ancestry of the library could take a while.
However the documentation says that objects have to model the Regular concept in order to model the Movable concept. This seems unfortunate as Regular puts a lot of requirements on types that don't seem necessary to gain moving. It requires Assignable which requires a copy constructor and it requires EqualityComparable which seems unnecessary.
Sorry, the documentation is out of date, I haven't updated it for the changes I've made. The library does supports noncopyable types. If you can decipher it there is an example in the unit tests (in y.hpp - I'll probably rename that file). You have to implement it a little differently to your normal noncopyable type. The signature is something like: class noncopyable { // Private constructor to make it noncopyable. // Note that it's a non-const reference noncopyable(noncopyable&); public: noncopyable(); ~noncopyable(); noncopyable(boost::move_from<noncopyable>); // Move constructor noncopyable& operator=(noncopyable); // Move assignment operator boost::move_from<noncopyable>() { return boost::move_from<noncopyable>(*const_cast<noncopyable*>(this)); } }; I should warn you that the library will probably change to support other types and hopefully rvalue references. I'll be resuming work on it soon after this release is done. Daniel

Daniel James wrote:
2008/7/31 Michael Marcin <mike.marcin@gmail.com>:
However the documentation says that objects have to model the Regular concept in order to model the Movable concept. This seems unfortunate as Regular puts a lot of requirements on types that don't seem necessary to gain moving. It requires Assignable which requires a copy constructor and it requires EqualityComparable which seems unnecessary.
Sorry, the documentation is out of date, I haven't updated it for the changes I've made. The library does supports noncopyable types. If you can decipher it there is an example in the unit tests (in y.hpp - I'll probably rename that file). You have to implement it a little differently to your normal noncopyable type. The signature is something like:
Fantastic. I sort of figured it does since I'm using them just wanted to make sure it was a feature and not a bug.
class noncopyable { // Private constructor to make it noncopyable. // Note that it's a non-const reference noncopyable(noncopyable&); public: noncopyable(); ~noncopyable(); noncopyable(boost::move_from<noncopyable>); // Move constructor noncopyable& operator=(noncopyable); // Move assignment operator boost::move_from<noncopyable>() { return boost::move_from<noncopyable>(*const_cast<noncopyable*>(this)); } };
The implicit conversion to move_from seems very dangerous to me.
I should warn you that the library will probably change to support other types and hopefully rvalue references. I'll be resuming work on it soon after this release is done.
I'm looking forward to it. Thanks, Michael Marcin

on Thu Jul 31 2008, "Daniel James" <daniel_james-AT-fmail.co.uk> wrote:
2008/7/31 Michael Marcin <mike.marcin@gmail.com>:
I'm using the current move library in the sanbox by daniel james (which I believe is the 4th move emulation library I've used now). It seems to be very good so far and makes writing code that handles both move and copy a breeze. I hope this gets finalized and ready for review soon because a consistently used move emulation library would be a great aid to writing efficient libraries that work well together.
I'm pleased (and slightly surprised) that it's already getting use. To give credit where it's due, most of it is based on work by Adobe and David Abrahams. I also took some code from the move emulation in the thread library and the old move library. Tracing the complete ancestry of the library could take a while.
Yeah, I would be very interested in seeing how those pieces go together. By the way, I should send you some ideas I had recently about how to move swappable but not-otherwise-move-enabled types. -- Dave Abrahams BoostPro Computing http://www.boostpro.com
participants (3)
-
Daniel James
-
David Abrahams
-
Michael Marcin