Subject: Re: [boost] [variant] Please vote for behavior (Was: Basic rvalue and C++11 features seupport)
From: Sergey Cheban (s.cheban_at_[hidden])
Date: 2013-01-21 17:52:02
21.01.2013 23:37, Andrey Semashev Ð¿Ð¸ÑÐµÑ:
> On January 21, 2013 11:27:36 PM Sergey Cheban <s.cheban_at_[hidden]> wrote:
>>> II: Set operand.p_ to NULL, add BOOST_ASSERT in get operations
>>> + 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
>>> - triggers an assert when user tries to reuse moved object
>>> - adds an empty state to the recursive_wrapper
>> Let's think about non-recursive variants. For example:
>> // both CFileObj and CDatabaseObj are movable, not copyable and
>> // not nothrow-default-constructible
>> boost::variant< CFileObj, CDatabaseObj > v1( CFileObj(SomeFileName) );
>> boost::variant< CFileObj, CDatabaseObj > v2( std::move( v1 ) );
>> // What would be the state of v1 at this point?
> Moved-from CFileObj, I presume.
So, the reasonable and consistent value for the moved-from
variant<recursive_wrapper,int> is a moved-from recursive_wrapper, right?
In many cases, the moved-from state of the variables is equal to the
default-constructed state but this rule is not obligatory.
So, I think that NULL is a valid state of the moved-from
recursive_wrapper and the 2nd proposal is not worse (at least) than the
-- Best regards, Sergey Cheban