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

Understanding the example on lvalue-to-rvalue conversion

This is because y.n is not odr-used and therefore does not require an access to y.n the rules for odr-use are covered in 3.2 and says: A variable x whose name appears as a potentially-evaluated expression ex is odr-used unless applying the lvalue-to-rvalue conversion (4.1) to x yields a constant expression (5.19) that does not … Read more