Boost logo

Boost :

Subject: Re: [boost] [variant] Basic rvalue and C++11 features support
From: Nevin Liber (nevin_at_[hidden])
Date: 2013-01-08 12:28:35

On 8 January 2013 08:18, Hartmut Kaiser <hartmut.kaiser_at_[hidden]> wrote:

> The only thing the standard requires wrt a moved-from object is that they
> are left in a valid (although unspecified) state. Thus simply nulling out
> the pointer in the reference_wrapper should do the trick (just as Joel
> proposed).
> See for instance: - [lib.types.movedfrom]
> <quote>
> Objects of types defined in the C++ standard library may be moved from
> (12.8). Move operations may
> be explicitly specified or implicitly generated. Unless otherwise
> specified,
> such moved-from objects shall be
> placed in a valid but unspecified state.
> </quote>

If I remember correctly, that section was added at the 11th hour so to
speak (at the Madrid meeting, days before ratifying the standard) so we
didn't have to go through the entire library figuring out and documenting
which operations were and were not legal to call on moved-from standard
library objects.

Other than destroyable and (possibly) assignable, it really is up to the
author of the class to define what operations are allowed on moved-from
objects. In other words, authors are allowed to make "not in the
moved-from state" as a precondition for operations they don't want to allow
in that state.

A nulled-out pointer in the reference wrapper meets this requirement.

 Nevin ":-)" Liber  <mailto:nevin_at_[hidden]>  (847) 691-1404

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