Move assignment operator
A move assignment operator is a C++ special member function that replaces an existing object's state by transferring resources from another object.
100 C++ Mistakes and How to Avoid Them
A move assignment operator is a C++ special member function that transfers resources from a source object into an already existing target object.
- How it is used
- Uses move assignment to transfer ownership into existing objects without copying resource contents.
- How deep it goes
- Walks through resource cleanup, self-assignment, pointer transfer, and source neutralization, and shows a defaulted alternative.
- Examples
- Uses an InputReader dynamic array and a Page with a unique_ptr body to illustrate explicit and defaulted moves.
- What you can do after
- Enables readers to evaluate or implement move assignment while accounting for existing resources and the moved-from object.
Read how 100 C++ Mistakes and How to Avoid Them explains move assignment operator →
Learn C++ by Example
A move assignment operator is a class member function that replaces an object's state by transferring resources from another object, typically an rvalue.
- How it is used
- Uses move assignment to reason about special-member behavior, resource management, and move-enabled library operations.
- How deep it goes
- Defines its special-member role and tests availability with type traits, but stops short of implementing a resource-owning operator.
- Examples
- Uses vector `push_back`, an abstract `Blob`, and `std::is_move_assignable_v` assertions as concrete examples.
- What you can do after
- Evaluate whether a class supports move assignment and predict when library code falls back to copying.
Read how Learn C++ by Example explains move assignment operator →
What to know first
- copy assignment operatorA copy assignment operator is a C++ special member function that copies state from one object into an already existing object of a compatible type.
- undefined behaviorUndefined behavior is program execution or an operation for which the applicable specification imposes no requirements on the resulting behavior.
Related concepts
- moveimplements · Move semantics are language rules that transfer a value or its resources to another binding or object without copying them, potentially making the original binding unavailable.
- operatorkind of · An operator is a symbol, keyword, or language construct that specifies an operation on one or more operands.
- copy assignment operatorcontrasts with · A copy assignment operator is a C++ special member function that copies state from one object into an already existing object of a compatible type.
Questions about move assignment operator
What is move assignment operator?
A move assignment operator is a C++ special member function that replaces an existing object's state by transferring resources from another object.
Which Manning books explain move assignment operator?
100 C++ Mistakes and How to Avoid Them and Learn C++ by Example.
What should I know before learning move assignment operator?
Manning books that teach move assignment operator usually introduce copy assignment operator and undefined behavior first.
What is the difference between move assignment operator and copy assignment operator?
A move assignment operator is a C++ special member function that replaces an existing object's state by transferring resources from another object. A copy assignment operator is a C++ special member function that copies state from one object into an already existing object of a compatible type.
What is move assignment operator a kind of?
Move assignment operator is a kind of operator. An operator is a symbol, keyword, or language construct that specifies an operation on one or more operands.
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.

