Consider a simple handle class that owns a resource and also provides copy
semantics (copy constructor and assignment). For example a clone_ptr might own a pointer, and call
clone()
on it for copying purposes:

clone_ptr has expected copy
constructor and assignment semantics, duplicating resources when copying.
Note that copy constructing or assigning a clone_ptr
is a relatively expensive operation:

clone_ptr<Base>p1(newDerived());// ...clone_ptr<Base>p2=p1;// p2 and p1 each own their own pointer

clone_ptr is code that you
might find in today's books on C++, except for the part marked as movesemantics.
That part is implemented in terms of C++0x rvaluereferences. You can find some good
introduction and tutorials on rvalue references in these papers:

When the source of the copy is known to be an rvalue
(e.g.: a temporary object), one can avoid the potentially expensive clone()
operation by pilfering source's pointer (no one will notice!). The move constructor
above does exactly that, leaving the rvalue in a default constructed state.
The move assignment operator simply does the same freeing old resources.

Now when code tries to copy an rvalue clone_ptr,
or if that code explicitly gives permission to consider the source of the
copy an rvalue (using boost::move),
the operation will execute much faster.

clone_ptr<Base>p1(newDerived());// ...clone_ptr<Base>p2=boost::move(p1);// p2 now owns the pointer instead of p1p2=clone_ptr<Base>(newDerived());// temporary is moved to p2}

Many aspects of move semantics can be emulated for compilers not supporting
rvaluereferences
and Boost.Move offers tools for that purpose.
With Boost.Move we can write clone_ptr so that it will work both in
compilers with rvalue references and those who conform to C++03. You just
need to follow these simple steps: