I am reviewing some code like this, where A is a moveable type:
// Returns true exactly when ownership of a is taken
bool MaybeConsume(A&& a) {
  if (some condition) {
    Consume(std::move(a));  // ???
    return true;
  }
  return false;
}
// ... elsewhere ...
A a;
if (!MaybeConsume(std::move(a))) {
  a.DoSomething();  // !!!
}
Our static analysis tool complains that a is used after being moved (at !!!). IIUC std::move is only a static_cast, and the object a won't actually get gutted until a move constructor or assignment operator is called (presumably in Consume). Assuming MaybeConsume satisfies the contract in the comment,
- Does this work?
- Is it UB?
- Is std::moveat???a no-op?
(Probably this particular instance can be refactored to avoid the subtlety, but I would still like to ask for my own understanding).
 
     
    