
On Fri, Jan 11, 2013 at 5:22 PM, Peter Dimov <lists@pdimov.com> wrote:
Paul Smith wrote:
That's the first constructive solution so far. Something like:
template <typename T> struct is_legitimate_move_target // specialize me : has_trivial_constructor<T> {};
has_nothrow_default_constructor is enough. There's no need to introduce a separate trait.
Read
http://www.boost.org/doc/libs/1_52_0/doc/html/variant/design.html#variant.de...
people. It's all explained there.
Even though it's called the "never-empty guarantee", I always thought that variant actually provides a strong exception guarantee (i.e. the variant is not just left unempty, but specifically in the previous state) so it's not directly relevant. Am I wrong? Anyway, there's no need to outright disallow move in any case. The goal is simply to find a good move target. Automatically assuming that a non-throwing default constructor is a good move target is a heuristic. A good one, but still a heuristic. A trivial default constructor looks like the most sensible default. If the user thinks otherwise, let him specialize the move-oriented trait. -- Paul Smith