|
Boost : |
Subject: Re: [boost] [variant] Basic rvalue and C++11 features support
From: Eric Niebler (eric_at_[hidden])
Date: 2013-01-08 16:56:25
On 1/8/2013 1:11 PM, Dave Abrahams wrote:
>
> on Mon Jan 07 2013, Eric Niebler <eric-AT-boostpro.com> wrote:
>
>> On 1/7/2013 12:14 PM, Paul Smith wrote:
>>> A recursive_wrapper is not a pointer. It's a value-like wrapper
>>> that is assumed to always contain a valid object. The move
>>> constructor should leave the moved-from recursive_wrapper
>>> in a valid state, which precludes nullifying it.
>>
>> Paul, I think you are confused about move semantics. Joel and Hartmut
>> are right. Nobody should ever be seeing a moved-from object.
>
> No, Paul is right on the money. The moved-from state is part of the
> object's invariant, and objects in that state may become exposed in
> several ways (e.g. use std::remove on a sequence of them). If you want
> a given class to have an empty moved-from state, that's fine... but you
> can't claim the object is invalid after a valid operation is used on it.
> You have to document the client-visible consequences of that state as
> part of the object's behavior, etc.
Yes, I'd already figured out that Paul knows what he's talking about,
and I apparently don't, so I've shut up. :-) This discussion has been
fascinating, and I've learned a lot. Thanks.
>> Move constructors and assignment operators exist precisely to enable
>> this kind of optimization.
>
> True, but irrelevant. :-)
I admit that I find this somewhat disappointing. I'm now readjusting my
expectations of move semantics.
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk