All challenges
Multiple ChoiceBeginner 45s

Moved-from object guarantees

After `std::vector<int> b = std::move(a);` where a was non-empty, what is guaranteed about `a`?
Options
  1. 1It is guaranteed to be empty, because the move constructor always leaves the source cleared.
  2. 2It is guaranteed to retain its elements, because the move only transfers the buffer pointer.
  3. 3It is left in a state where any method call is undefined behavior until it is reassigned.
  4. 4It is in a valid but unspecified state; only operations without preconditions (like clear(), assignment) are safe.

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