
2013/1/21 Antony Polukhin <antoshkka@gmail.com>
Current implementation of recursive_wrapper move constructor is not optimal:
recursive_wrapper<T>::recursive_wrapper(recursive_wrapper&& operand) : p_(new T(std::move(operand.get()) )) { }
During descussion were made following proposals:
[...] II: Set operand.p_ to NULL, add BOOST_ASSERT in get operations
I vote for II, because: + good performance
+ provides noexcept guarantee for move constructor + optimization will be used even if varinat has no type with trivial default constructor + easy to implement
And the above 4 points mean to me that it is a simple solution, which does the job. - triggers an assert when user tries to reuse moved object
Yes, using the moved object in other cases then assigning something to it is UB, so that's the right thing to do ;-) - adds an empty state to the recursive_wrapper This empty state can only be achieved by moving from the object, right? That's fine with me. Regards, Kris