Practice mode C++

What does std::move actually do to its argument?

Correct answer D. It casts it to an rvalue reference so move operations can be selected

Explanation

std::move is essentially static_cast. It performs no data transfer itself; it only marks the expression as an rvalue so overload resolution can choose a move constructor or move assignment operator. The actual moving, and the state left behind in the source object, depends on those functions. If a type has no move operations, the copy operations are used instead.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.