fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. void foo(std::string& s) { std::cout << "l-value reference" << std::endl; }
  5. void foo(std::string&& s) { std::cout << "r-value reference" << std::endl; }
  6.  
  7. int main(int argc, char* argv[])
  8. {
  9. std::string s;
  10. foo(s);
  11. foo(std::string());
  12.  
  13. return 0;
  14. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
l-value reference
r-value reference