fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. string f(std::string&& s)
  5. {
  6. std::string res(std::move(s));
  7. res += " plus extra";
  8. return res;
  9. }
  10.  
  11. int main(void)
  12. {
  13. std::string str = "A string";
  14. cout << f( std::move(str) ) << endl;
  15. std::cout << "'" << str << "'" << std::endl; // Unspecified behavior
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
A string plus extra
''