
on Fri Jan 09 2009, Steven Watanabe <watanabesj-AT-gmail.com> wrote:
AMDG
David Abrahams wrote:
David Abrahams wrote:
So you're saying, in other words, that "move(x)" really means "you have permission to move x" but the one I proposed would mean "move it, now."
OK, good point.
So what about this horrible little proposal?
template <class T> struct rv<T> : T { private: rv(); ~rv(); rv(rv const&); void operator=(rv const&); };
template <class T> boost::enable_if<is_class<T>, rv<T>&> move(T& x) { return static_cast<rv<T>& >(x); }
Does that solve any problems?
Well, I haven't thought this through deeply (nor really tested anything), but the idea is that movable types would have a stealing conversion from rv<T>& but non-movable types should just use the copy ctor that slices off the non-existent derived class.
What if T has a fully generic constructor?
That's detectable, at least. For such types, you disable this move unless some trait is specialized. -- Dave Abrahams BoostPro Computing http://www.boostpro.com