If I move a local object into a function, will it still be valid afterward?

Viewed 996

So, this provides the intended output:

void f(std::string&& s)
{
   s += " plus extra";
}

int main(void)
{
   std::string str = "A string";
   f( std::move(str) );
   std::cout << str << std::endl;

   return 0;
}

A string plus extra

That is, it works when I run it on Ideone, but is it UB? Adding extra string initializations before and after the call to f didn't change anything.

4 Answers
Related