Boost logo

Boost :

Subject: Re: [boost] [variant] Basic rvalue and C++11 features support
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2013-01-10 22:38:07


On Jan 10, 2013, at 6:29 PM, Joel de Guzman <djowel_at_[hidden]> wrote:

> On 1/9/13 11:03 PM, Paul Smith wrote:
>> On Tue, Jan 8, 2013 at 8:48 PM, Peter Dimov <lists_at_[hidden]> wrote:
>>> Paul Smith wrote:
>>>>
>>>> The only way to make everyone happy is to guarantee that a moved-from
>>>> recursive variant is a valid variant.
>>>
>>> Well, the performance hit from `new T` is making a lot of people unhappy, so
>>> technically, this is not true. :-)
>>
>> Unfortunately, that's probably not the worst thing about it. The fact that it can also throw is the one that has the more subtle and far reaching consequences.
>
> And that is utterly disappointing. This "conservative" move makes all proxy-like objects with pointer ownership very inefficient! While we are advocating pass by value!
>
> So... can anyone finally give a good definition of what "valid" means?

Validity depends upon the class in question. A smart pointer can be null and still valid. In your case, the class has the semantics that it always references a value. Changing that, to permit a null state, may be acceptable or it may have unacceptable side effects. Perhaps a new type, with the null state, can be added and used in some of the current contexts.

That your tests passed after your changes suggests that Spirit might well use such a type without problem.

___
Rob


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk