
On 8 January 2013 08:18, Hartmut Kaiser <hartmut.kaiser@gmail.com> 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: 17.6.5.15 - [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@eviloverlord.com> (847) 691-1404