fork(12) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A
  5. {
  6. A() {s = "initial"; cout << "ctor" << endl;}
  7. A(const A&a) {s = a.s; cout << "copy" << endl;}
  8. A(A&&a) { s = std::move(a.s); cout << "move" << endl;}
  9. A& operator=(const A&a) { s = a.s; cout << "copy=" << endl;}
  10. A& operator=(A&&a) {s = std::move(a.s); cout << "move=" << endl;}
  11. string s;
  12. };
  13.  
  14. int main() {
  15. A a;
  16. try {
  17. throw a;
  18. }
  19. catch(const A& ta){
  20. cout << ta.s << endl;
  21. }
  22. cout << a.s;
  23. // your code goes here
  24. return 0;
  25. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
ctor
move
initial