Boost.Move Where we are with move semantic emulation on C++03 compilers?

Hi, Some weeks ago Howard Hinnant presented on this ML a quite satisfactory emulation of C++0x move semantics. There is also Boost.Move, the adaptation to boost by Daniel James of the Adobe implementation, which was inspired by the move library written by Dave Abrahams and the work on move done by Dave Abrahams and Howard Hinnant. This library is esential to avoid a profusion of move emulation implementation on each library and start to build generics with move semantics. Can we expect to have a proposal for review soon? Thanks, Vicente

vicente.botet wrote:
Hi,
Some weeks ago Howard Hinnant presented on this ML a quite satisfactory emulation of C++0x move semantics. There is also Boost.Move, the adaptation to boost by Daniel James of the Adobe implementation, which was inspired by the move library written by Dave Abrahams and the work on move done by Dave Abrahams and Howard Hinnant.
I tried to make some noise (and work) but I just run out of time.
Can we expect to have a proposal for review soon?
I hope so. Dave's latest proposal was very promising.
Thanks, Vicente
Regards, Ion

2009/2/4 Ion Gaztañaga <igaztanaga@gmail.com>:
vicente.botet wrote:
Some weeks ago Howard Hinnant presented on this ML a quite satisfactory emulation of C++0x move semantics. There is also Boost.Move, the adaptation to boost by Daniel James of the Adobe implementation, which was inspired by the move library written by Dave Abrahams and the work on move done by Dave Abrahams and Howard Hinnant.
I tried to make some noise (and work) but I just run out of time.
Does that mean you're not working on it anymore? Daniel

Daniel James wrote:
Does that mean you're not working on it anymore?
No, I'm working on it. Right now writing some Quickbook documentation. But I have a question on perfect forwarding: has anybody implemented perfect forwarding using boost preprocessor? I mean something that generates a call with all the combinations of const and non-const references: function() function(const T0 &t0) function(T0 &t0) function(const T0 &t0, const T1 &t1) function(const T0 &t0, T1 &t1) function(T0 &t0, const T1 &t1) function(T0 &t0, T1 &t1) //.... I would like to add this to the library to have a good "forward" emulation and I really don't know how to use Boost.Preprocessor to generate such thing. Any help is appreciated. Regards, Ion

Ion Gaztañaga wrote:
Daniel James wrote:
Does that mean you're not working on it anymore?
No, I'm working on it. Right now writing some Quickbook documentation. But I have a question on perfect forwarding: has anybody implemented perfect forwarding using boost preprocessor?
I mean something that generates a call with all the combinations of const and non-const references:
function() function(const T0 &t0) function(T0 &t0) function(const T0 &t0, const T1 &t1) function(const T0 &t0, T1 &t1) function(T0 &t0, const T1 &t1) function(T0 &t0, T1 &t1) //....
I would like to add this to the library to have a good "forward" emulation and I really don't know how to use Boost.Preprocessor to generate such thing. Any help is appreciated.
It's not hard to add with BOOST_PP_SEQ_FOR_EACH_PRODUCT, as done here: http://lists.boost.org/Archives/boost/att-105224/01-part But please make it optional and in a separate header. It's very compile-time expensive. -- Eric Niebler BoostPro Computing http://www.boostpro.com

on Thu Feb 12 2009, Ion Gaztañaga <igaztanaga-AT-gmail.com> wrote:
Daniel James wrote:
Does that mean you're not working on it anymore?
No, I'm working on it. Right now writing some Quickbook documentation. But I have a question on perfect forwarding: has anybody implemented perfect forwarding using boost preprocessor?
I mean something that generates a call with all the combinations of const and non-const references:
function() function(const T0 &t0) function(T0 &t0) function(const T0 &t0, const T1 &t1) function(const T0 &t0, T1 &t1) function(T0 &t0, const T1 &t1) function(T0 &t0, T1 &t1) //....
Yeah, I did. And then Paul Mensonides optimized it for me, although I'm not sure I know how to find that version. Maybe this is that version and I forgot to credit him (if so, sorry, Paul!) http://article.gmane.org/gmane.comp.lib.boost.devel/140159 That's not exactly perfect forwarding, though: it erases rvalue-ness. That means you lose the ability to move from the argument inside the forwarding function. -- Dave Abrahams BoostPro Computing http://www.boostpro.com

on Thu Feb 12 2009, David Abrahams <dave-AT-boostpro.com> wrote:
on Thu Feb 12 2009, Ion Gaztañaga <igaztanaga-AT-gmail.com> wrote:
Daniel James wrote:
Does that mean you're not working on it anymore?
No, I'm working on it. Right now writing some Quickbook documentation. But I have a question on perfect forwarding: has anybody implemented perfect forwarding using boost preprocessor?
I mean something that generates a call with all the combinations of const and non-const references:
function() function(const T0 &t0) function(T0 &t0) function(const T0 &t0, const T1 &t1) function(const T0 &t0, T1 &t1) function(T0 &t0, const T1 &t1) function(T0 &t0, T1 &t1) //....
Yeah, I did. And then Paul Mensonides optimized it for me, although I'm not sure I know how to find that version. Maybe this is that version and I forgot to credit him (if so, sorry, Paul!)
Oh, Eric posted a link to the fast one (that credits Paul's work). -- Dave Abrahams BoostPro Computing http://www.boostpro.com

David Abrahams wrote:
Oh, Eric posted a link to the fast one (that credits Paul's work).
Thanks Dave and Eric for the link. Until now in my libraries I was using a forwarding like this (warning, fast witten, not compiled code) //move template<class Movable> boost::rv<Movable> & move (Movable &m); //forward template<class RvalueRef> RvalueRef & forward ( const RvalueRef &r , typename enable_if<is_boost_rv<RvalueRef> >::type = 0 ) { return const_cast<RvalueRef &>(r); } template<class T> const T &forward ( const T &r , typename disable_if<is_boost_rv<T>>::type = 0 ) { return r; } //emplace function of a container //Simple preprocessor expansion: template<class T0, class T1, ...> void emplace_back(const T0 &t0, const T1 &t1, ....) { addr = allocate(); new(addr)(boost::forward<T0>(t0), boost::forward<T1>(t1), ...); } so I could do something like: handle get_handle(); movable_only get_movable_only() { Container<movable_only> container; movable_only m(get_movable_only()); container.emplace(get_handle(), move(m)); //This does not compile container.emplace(get_movable_only(), move(m)); //This fowards r as a const reference container.emplace(r); } Non-const references were not forwarded, but this usually was enough for common container use cases (constructors taking non-const references are not usual). I don't know if this would be acceptable for a move emulation library or a complete overload set would be required. Another possibility is to add a restriction and use boost::ref to pass non-const references so forward() could detect them. template<class T> T &forward ( const boost::reference_wrapper<T> &r , typename disable_if<is_boost_rv<T>>::type = 0 ) { return r.get(); } Thanks again for the link, Ion

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 12 February 2009 12:19 pm, Ion Gaztañaga wrote:
No, I'm working on it. Right now writing some Quickbook documentation. But I have a question on perfect forwarding: has anybody implemented perfect forwarding using boost preprocessor?
I've never used it, but isn't perfect forwarding what Boost.Functional/Forward is supposed to support? It was accepted over a year ago and is on svn trunk, but it looks like it was never merged into the release branch. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFJlGyI5vihyNWuA4URAidFAJ9x9Bmut6ZdypwGd/zVx1LiYlezLQCcDSru vP1rY3IlyVgv3dho5dbn0oo= =Mroi -----END PGP SIGNATURE-----

on Wed Feb 04 2009, Ion Gaztañaga <igaztanaga-AT-gmail.com> wrote:
Hi,
Some weeks ago Howard Hinnant presented on this ML a quite satisfactory emulation of C++0x move semantics. There is also Boost.Move, the adaptation to boost by Daniel James of the Adobe implementation, which was inspired by the move library written by Dave Abrahams and
vicente.botet wrote: the work on move done by Dave Abrahams and Howard Hinnant.
I tried to make some noise (and work) but I just run out of time.
Can we expect to have a proposal for review soon?
I hope so. Dave's latest proposal was very promising.
Hmm? I made a proposal? Maybe I'm just getting too old to remember what I did last month, but honestly, I don't. -- Dave Abrahams BoostPro Computing http://www.boostpro.com
participants (6)
-
Daniel James
-
David Abrahams
-
Eric Niebler
-
Frank Mori Hess
-
Ion Gaztañaga
-
vicente.botet