1 | class Widget { |
Conclusion:
- use std::move to rvalue references and std::forward to universal references the last time each is used
- Do the same thing for rvalue references and universal references being returned from functions that return by value
- Never apply std::move or std::forward to local objects if they would otherwise be eligible for the return value optimization (RVO)
- std::move performs an unconditional cast to an rvalue. In and of itself, it doesn’t move anything
- std::forward casts its argument to an rvalue only if that argument is bound to an rvalue
- Neither std::move nor std::forward do anything at runtime