← Quiz: Move Semantics and rvalue References: all 10 questions
Quiz: Move Semantics and rvalue References · Question 2 of 10
What does std::move(x) actually do?
What does std::move(x) actually do?
- A.Copies x into a new object
- B.Casts x to an rvalue so that a move constructor or move assignment can be chosen
- C.Frees the memory owned by x
- D.Moves x to the heap
Answer & explanation
Correct answer: Casts x to an rvalue so that a move constructor or move assignment can be chosen
std::move is only a cast. The stealing happens in the function that receives the rvalue.
Can you get the rest right without peeking?
Take the timed Quiz: Move Semantics and rvalue References quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →