fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. struct Foo {
  6. Foo() = default;
  7. Foo(const Foo&) {
  8. cout << __PRETTY_FUNCTION__ << endl;
  9. }
  10. Foo(Foo&&) {
  11. cout << __PRETTY_FUNCTION__ << endl;
  12. }
  13. };
  14.  
  15. struct Bar {
  16. operator Foo() const {
  17. Foo f;
  18. return f;
  19. }
  20. };
  21.  
  22. Foo getFoo() {
  23. if (rand() % 2 == 0)
  24. throw "something wrong";
  25. Bar b;
  26. return b;
  27. }
  28.  
  29. int main() {
  30. auto foo = getFoo();
  31. return 0;
  32. }
Success #stdin #stdout 0s 15224KB
stdin
Standard input is empty
stdout
Standard output is empty