Boost logo

Boost :

Subject: Re: [boost] [variant] Basic rvalue and C++11 features support
From: Dave Abrahams (dave_at_[hidden])
Date: 2013-01-08 16:11:44

on Mon Jan 07 2013, Eric Niebler <> 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.

> Move constructors and assignment operators exist precisely to enable
> this kind of optimization.

True, but irrelevant. :-)

Dave Abrahams
BoostPro Computing                  Software Development        Training             Clang/LLVM/EDG Compilers  C++  Boost

Boost list run by bdawes at, gregod at, cpdaniel at, john at