fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct T {
  5. int x;
  6. T() : x(1) { cout << "create" << endl; }
  7. T(int _x) : x(_x) { cout << "create(x)" << endl; }
  8. T(T &t) { cout << "copy" << endl; }
  9. T(T &&t) { cout << "move" << endl; }
  10.  
  11. operator int() { return x; }
  12. T operator+(T &t) { x += t.x; return *this; }
  13. };
  14.  
  15. T f()
  16. {
  17. T a(1);
  18. if (a == 1) return a + a;
  19.  
  20. return a;
  21. }
  22.  
  23. int main() {
  24.  
  25. T a = f();
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 2928KB
stdin
Standard input is empty
stdout
create(x)
copy