fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. void func(string &&a) { cout << "#1" << endl; }
  7. void func(const string &&a) { cout << "#2" << endl; }
  8. void func(int &&a) { cout << "#3" << endl; }
  9. void func(const int &&a) { cout << "#4" << endl; }
  10.  
  11. int main()
  12. {
  13. func(string("1")); // call func(string &&)
  14. func((const string)string("1")); // call func(const string &&)
  15. func(1); // call func(int &&)
  16. func((const int)1); // call func(int &&) not func(const int &&)
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
#1
#2
#3
#4