What is std::move(), and when should it be used and does it actually move anything?

1. “What is it?” While std::move() is technically a function – I would say it isn’t really a function. It’s sort of a converter between ways the compiler considers an expression’s value. 2. “What does it do?” The first thing to note is that std::move() doesn’t actually move anything. It changes an expression from being … Read more

Why doesn’t C++ move construct rvalue references by default? [duplicate]

with your design: void doWork(Widget && param) { Widget store1 = param; // automatically move param Widget store2 = param; // boom Widget store_last = param; // boom } with current design: void doWork(Widget && param) { Widget store1 = param; // ok, copy Widget store2 = param; // ok, copy Widget store_last = std::move(param); … Read more