Std::move
std::move is a C++ standard-library function template that casts an expression to an rvalue reference, enabling move operations.
100 C++ Mistakes and How to Avoid Them
std::move is a C++ standard library function template that casts an expression to an rvalue reference to enable move operations.
- How it is used
- Enables move construction or assignment when transferring resource ownership instead of performing standard copying.
- How deep it goes
- Explains the cast and moved-from state, then demonstrates pointer transfer in move construction and unique_ptr ownership.
- Examples
- Uses Page pointer transfer and Buffer ownership transfer through unique_ptr.
- What you can do after
- Apply std::move to eligible lvalues and handle moved-from objects cautiously during resource ownership transfers.
Read how 100 C++ Mistakes and How to Avoid Them explains std::move →
C++ Concurrency in Action, Second Edition
`std::move` is a C++ standard library function template that casts an expression to an rvalue reference, enabling move operations.
- How it is used
- Transfers ownership of movable, noncopyable resources such as `std::thread` and `std::unique_ptr`.
- How deep it goes
- Works through named and temporary sources, ownership changes, and a thread-assignment failure, without detailing move internals.
- Examples
- Uses thread transfers among three objects and transfers a `std::unique_ptr` into a thread function.
- What you can do after
- Apply it via `std::move` to transfer ownership from named objects and recognize when thread replacement would terminate.
Read how C++ Concurrency in Action, Second Edition explains std::move →
Learn C++ by Example
std::move is a C++ standard library utility that casts an expression to an rvalue reference to enable moving from it.
- How it is used
- Enables efficient forwarding into vector operations by selecting rvalue overloads and avoiding unnecessary copies.
- How deep it goes
- Explains named rvalue references, overload selection, and moved-from states, but deliberately scratches only the surface of perfect forwarding.
- Examples
- Uses vector insertion, a triangle-row generator, push_back overloads, and direct emplace_back calls.
- What you can do after
- Apply std::move to forward named values as rvalues and recognize when an operation may move instead of copy.
Related concepts
- rvalueproduces · An rvalue is an expression that does not designate an assignable object and provides a value or temporary object for use in computation.
- std::threadused by · A C++ standard library class that represents and manages a thread of execution.
- unique_lockused by · std::unique_lock is a C++ standard library class template that manages exclusive ownership of a mutex and supports deferred locking, unlocking, and ownership transfer.
- std::unique_ptrused by · std::unique_ptr is a C++ standard-library smart pointer that provides exclusive ownership of a dynamically allocated object and manages its lifetime.
- moveimplements · Move semantics describe the transfer of a value or its resources to another binding or object rather than duplicating them.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


