fork download
  1. #include <string>
  2. #include <iostream>
  3.  
  4. std::string &concat( std::string &a, const std::string &b ) {
  5. a += b;
  6. return a;
  7. }
  8. std::string &concat( std::string &&a, const std::string &b ) {
  9. a += b;
  10. return a;
  11. }
  12.  
  13. int main( void ) {
  14. std::string a = "abc";
  15. std::string b = "def";
  16. std::cout << concat( a, b ) << std::endl;
  17. std::cout << concat( a, (a + b) ) << std::endl;
  18. std::cout << concat( (a + b), b ) << std::endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
abcdef
abcdefabcdefdef
abcdefabcdefdefdefdef