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).

Leave a Comment