
On Mon, Jan 21, 2013 at 5:39 AM, Antony Polukhin <antoshkka@gmail.com>wrote:
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:
I: Leave it as is
[...]
II: Set operand.p_ to NULL, add BOOST_ASSERT in get operations
[...]
III: Make recursive_wrapper and variant cooperate, enable move for varinat in the presence of recursive_wrappers only when there is at least one type that is nothrow-default-constructible, regardless of whether it's current.
[...]
IV: After move away, delay construction of type held by recursive_wrapper till it will be be required.
[...]
Please, vote for solution or propose a better one.
IMHO, III is the only strictly correct solution, given variant's present never-empty guarantee (which the original author deemed pretty important, given the amount of documentation dedicated to it). Aside: recursive_wrapper is only used within the context of a variant, right? - Jeff