← Back to context

Comment by jjmarr

6 hours ago

> The moved object could be left in an unusable state, depending on your implementation, after stealing its internal resources.

The "proper" semantics are that it leaves the object in a valid but unspecified state. So, invariants still hold, you can call functions on it, or assign to it.

> you can call functions on it

Only functions with no preconditions, unless the type makes more guarantees as to the moved-from state.

  • The guarantees is that a moved-from state is in an otherwise valid state.

    So, you can do things like check if a moved from std::vector is empty (often the case in practice), then start appending elements to it.