All challenges
Multiple ChoiceIntermediate 45s

std::move in return statement pessimizes

Why is `return std::move(local_member);` generally considered an anti-pattern inside a function returning by value?
Options
  1. 1It causes a compile error because you cannot move a member out of an object inside a method.
  2. 2It makes std::move run twice, doubling the destructor calls on the returned local object here.
  3. 3It converts the operand to an rvalue reference in a way that suppresses copy elision for the return object.
  4. 4It is fine and always faster than plain `return local;`, since the cast enables elision there.

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle