English
Topic 8. Copying and moving objects, the RAII idiom, and the rules of zero, three, and five
Goal: learn to apply the concepts of the topic “Copying and moving objects, the RAII idiom, and the rules of zero, three, and five” in console projects; justify invariants and the contracts of operations; test both ordinary and edge cases.
Lecture contents
- Copy and move — Copying a value and copying an address · Move and noexcept
- RAII and the rules of zero, three, and five — RAII and the scope boundary · The rules of zero, three, and five
- Value categories and copy-and-swap — Value categories and references · Copy-and-swap and the exception guarantee · Returning values and copy elision · RAII for state and transactions
- Case studies and common mistakes — Checking the owner of a resource · A step-by-step audit of assignment for an owned buffer · A scenario matrix for the rule of five · How to choose a resource for an RAII wrapper · What value should remain after a move · Checking the strong guarantee without triggering undefined behavior · From a local guard to a composite operation