Move Constructors and Move Assignment
Implement move constructors and move assignment operators correctly.
Two Special Members
The move constructor and move assignment operator let your class take ownership of another instance s resources without copying.
Signature
Both take an rvalue reference to the same type.
class String {
public:
String(String&& other) noexcept; // move ctor
String& operator=(String&& other) noexcept; // move assign
};All lessons in this course
- Lvalue vs Rvalue The Distinction
- Rvalue References and the && Syntax
- std::move and std::forward
- Move Constructors and Move Assignment