← 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?
- A.It does not compile
- B.It copies the object twice
- C.It can block copy elision, and the compiler would move the local automatically anyway
- 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 →