Step 4 of 7
Return by value is free
Returning a local object by value doesn't copy it. When you return a temporary (return Widget(...);), C++17 guarantees the object is built directly in the caller's variable: no copy, no move. Returning a named local is almost always optimized the same way, and otherwise it's moved.
So write functions that return by value; don't return pointers or use out-parameters for performance.
Your turn: the Tracker struct counts copies. Write Tracker make_tracker(int id) so that creating one via your function performs zero copies. The test prints the copy count.
Previous: Move assignment and the rule of five Next: Moved-from objects