🎙 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 10 of 10

Why is return std::move(local); a bad habit?

Why is return std::move(local); a bad habit?

  1. A.It does not compile
  2. B.It copies the object twice
  3. C.It can block copy elision, and the compiler would move the local automatically anyway
  4. D.It deletes the local before returning
Answer & explanation

Correct answer: It can block copy elision, and the compiler would move the local automatically anyway

Returning a local by name already allows elision or an automatic move; adding std::move only removes options.

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 →