
On Fri, Jan 11, 2013 at 6:35 PM, Peter Dimov <lists@pdimov.com> wrote:
Paul Smith wrote:
Still, there's no need to supress move construction in the absence of a no-throw default constructible type.
No, you could still keep the current behavior.
I think this was affirmative, but I'm not sure.
Incidentally, now that I think of it, the first implementation strategy in
http://www.boost.org/doc/libs/1_52_0/doc/html/variant/design.html#variant.de...
is possible when the target type has a nothrow move constructor. You could move-construct the temporary backup, destroy the target and if the copy fails, move-construct it back. So the assignment would go along the following lines:
- if the types are the same, assign - if the source type has a nothrow copy* constructor, use it - if the target type has a nothrow move constructor, use it - if there is a nothrow-default-constructible type, use it - otherwise, do the heap backup thing
Sounds legit. On a similar note, we should probably use a nothrow default constructible type when move constructing a variant for any type with a throwing move-ctor, not just recursive_wrapper. -- Paul Smith