Unit 01 of 02
Ownership and Move Semantics
Smart pointers, move semantics and rvalue references, the rule of zero and the rule of five, non-copyable and non-movable types — each paired with the question of what an operation leaves in the source.
Published Updated
Lessons
- 01 Smart Pointers Naming what an operation leaves in the source after it runs on a unique_ptr, shared_ptr, or weak_ptr with four kinds: unchanged, changed, empty, unspecified. 12 min read
- 02 Move Semantics std::move is nothing but a type conversion; the actual move is done by the move constructor and the move assignment operator. Measuring what is left in the source after a std::string is moved. 13 min read
- 03 The Rule of Zero and the Rule of Five How writing a destructor suppresses the implicit move constructor, how the five special member functions depend on one another, and how the rule of zero reaches the same result without ever forming that dependency. 13 min read
- 04 Non-Copyable and Non-Movable Types Using = delete to forbid copying, moving, or both on a class; a resource emptying by a promise that comes from the class itself, not the standard. 12 min read