Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2002-02-04 18:27:23

Nice description and motivation for move semantics.

On Mon, 4 Feb 2002, Howard Hinnant wrote:
hinnan> What remains to be done is to settle on a uniform syntax for move
hinnan> semantics. John Maddock has suggested:
hinnan> T b = std::move(a);

Would this mean we'd also have to rely on cooperation from operator=?
Wouldn't it be better to keep things simple with something like this

std::move(a, b); // a -> b

hinnan> Perhaps boost::auto_vector could experiment with this. The big
hinnan> stumbling block I've had to date is allowing move from a temporary T,
hinnan> but disallowing move from a const T, and packaging this up in a
hinnan> relatively reusable package so that giving your class move semantics is
hinnan> no harder than giving it copy semantics.

Well, non-const member functions have the property that you can call them
on temporaries but not on const objects. So you could do this:


Of course, this would require invasive changes to current classes, and
couldn't have the same syntax for builtins.

Or perhaps we just need to file a DR to once again allow temporaries to be
bound to non-const references. On the surface that restriction made a lot
of sense, but deep down it was wrong.


 Jeremy Siek
 Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
 C++ Booster ( office phone: (812) 855-3608

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