|
Boost : |
Subject: Re: [boost] [variant] Basic rvalue and C++11 features support
From: Larry Evans (cppljevans_at_[hidden])
Date: 2013-01-11 10:10:08
On 01/11/13 08:59, Peter Dimov wrote:
> Larry Evans wrote:
>> Are you suggesting that move is enabled only if the current tag (the
>> variant<*>::which() result) indicates the current type is default
>> constructable?
>
> No, I'm suggesting that move (in the presence of recursive_wrappers) can
> be enabled only when there is at least one type that is
> nothrow-default-constructible, regardless of whether it's current.
>
> typedef variant<int, recursive_wrapper<foo>> V;
>
> V v1( std::move(v2) );
>
> This move-constructs v1 from v2 and leaves int() into v2.
>
Thanks for the clarification.
However, that seems to involve a lot of checking because you'd have
to check possibly all the bounded types to find one that
is nothrow-default-constructible. Wouldn't it be simpler
to define variant to have, implicitly, a nothrow-default-constructible
type something like the special_type<nothing_id> I mentioned
in my previous post or like the boost::blank which Andrey just
mentioned in his post?
-regards,
Larry
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk