🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Copies x into a new object
  2. B.Casts x to an rvalue so that a move constructor or move assignment can be chosen
  3. C.Frees the memory owned by x
  4. 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 →