Move Semantics
Lectures Referred
- Back to Basics: Move Semantics: CppCon 2021 --- Notes Start Here ---
- Motivation for move semantics
- Copying large objects is expensive
- Heap allocations are expensive
- Avoid Objects with names, but sometimes you need them
- std::move -> "I dont need this value here anymore, you can steal its resources"
- Rvalue references (T&&) -> can bind to temporaries (rvalues)
- Lvalue references (T&) -> can bind to named objects (lvalues)
- what move does is: casts an lvalue to an rvalue -> T& to T&&