fork download
  1. #include <iostream>
  2.  
  3. struct A {
  4. A(int) { std::cout << "A(int)\n"; }
  5. A(int, int) { std::cout << "A(int, int)\n"; }
  6.  
  7. A(A const &) { std::cout << "A(A const &)\n"; }
  8. A(A &&) { std::cout << "A(A &&)\n"; }
  9.  
  10. A &operator=(A const &) { std::cout << "operator=(A const &)\n"; return *this; }
  11. A &operator=(A &&) { std::cout << "operator=(A &&)\n"; return *this; };
  12.  
  13. ~A() { std::cout << "~A()\n"; }
  14. };
  15.  
  16. A handleSomeCase(bool someCase) {
  17. if(someCase)
  18. return A(1, 2);
  19. else
  20. return A(3);
  21. }
  22.  
  23. int main(int argc, char *argv[]) {
  24. A a = handleSomeCase(argc > 1);
  25. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
A(int)
~A()