Should a move constructor take a const or non-const rvalue reference?
It should be a non-const
rvalue reference.
If an object is placed in read-only memory, you can't steal resources from it, even if its formal lifetime is ending shortly. Objects created as const
in C++ are allowed to live in read-only memory (using const_cast
to try to change them results in undefined behavior).
A move constructor should normally take a non-const reference.
If it were possible to move from a const object it would usually imply that it was as efficient to copy an object as it was to "move" from it. At this point there is normally no benefit to having a move constructor.
You are also correct that if you have a variable that you are potentially going to want to move from then it will need to be non-const.
As I understand it this is the reason that Scott Meyers has changed his advice on returning objects of class type by value from functions for C++11. Returning objects by const qualified value does prevent unintentionally modification of a temporary object but it also inhibits moving from the return value.