
on Thu Jan 08 2009, Howard Hinnant <hinnant-AT-twcny.rr.com> wrote:
On Jan 8, 2009, at 12:42 PM, Ion GaztaƱaga wrote:
is quite problematic for container implementation. With the old emulation (that returned detail::rv<T>) this was possible:
class vector { void push_back(const value_type &); void push_back(boost::detail::rv<value_type>); }
Is it practical to do this instead?
class vector { void push_back(value_type x); // internally move construct from x }
You take a performance hit on lvalue copyable expressions which are expensive to move. But it gives you the functionality of:
class vector { void push_back(const value_type&); void push_back(value_type&&); }
And there is no hit on rvalue expressions (if I recall correctly, it has been a little while since I did this survey).
I don't know, but from conversations with Sean, I suspect this is the direction the Adobe move emulation took.
IIRC, that is the "first cut" direction it took, but you can do something uglier and more complex when you want to optimize the expensive-to-move lvalue copyable expressions. Take a look at their container implementations. -- Dave Abrahams BoostPro Computing http://www.boostpro.com