1. It's non-trivial to determine if a moved-from object is in a valid state or not. In //base (and Chrome), we should try to be clear about it, e.g.
- moved-from smart pointers will be null
- moved-from callbacks will be null
- use-after-move is altogether disallowed for some other types (e.g. raw_ref<T>)
But it can be far less obvious for things in the STL
- is a moved-from std::string empty? (no, not necessarily)
- is a moved-from std::vector<T> empty? (usually but not always)
2. "They tend to gloss over the fact that objects often have methods that are perfectly safe to call after a move (especially stuff like a "reset" or "clear" that unconditionally puts the object into a known state) [...] I must admit I am a little worried as I've had a few too many experiences with people who believed that touching a moved-from object was almost always undefined behavior."
- Our guidance specifically states that it's fine to assign to it.
- The original text was written before we had clang-tidy's use-after-move warnings. Methods like Reset() and clear() should be annotated with REINITIALIZES_AFTER_MOVE to explicitly allow their use to put something into a known state.
- I would support adding a bit more nuance but I would certainly not encourage writing code that depends on the moved-from state of a standard library object if it is not explicitly specified.
Daniel