Q:

Passing rvalue to function that may not use it

Lets say I have a class defined as follows:
class Foo {
public:
    ...
    bool add_widget(Widget&& w) {
        if (some condition) {
            return false;
        }

        container.push_back(std::move(w));
        return true;
    }

private:
    std::deque<Widget> container;
}

and I call the class as follows:
int main(int argc, char* argv[]) {
    Foo f;
    Widget w;

    if (!f.add_widget(std::move(w))) {
        // Can I still use w here?
    }
}

If some condition is true, the Widget w will not be added to Foo's container. In main(), when add_widget() returns indicating that the add was not successful, can I still use w, or should I always assume it has been moved and is no longer usable?
Is it bad practice to write a function like add_widget() that takes an r-value reference but may not actually move it's argument?

A:

If "some condition" evaluates to true then the add_widget member function will return before the input w is moved in deque. Thus, you can use w in main safely. 
Have in mind that std::move doesn't actually move an object. std::move is nothing more than a type cast.
Even if w was moved then w in main would have been in a valid but unspecified state. 
Meaning that you could perform any operation on w which would have no preconditions. If there's an operation with preconditions you would like to perform, then you would have to perform that operation indirectly, because you wouldn't know if the unspecified-state of the object satisfies the preconditions.
LIVE DEMO

