fork download
  1. #pragma hdrstop
  2. #pragma argsused
  3.  
  4. #include <iostream>
  5. #include <string>
  6.  
  7. using std::cout;
  8. using std::endl;
  9.  
  10. class Test {
  11. public:
  12. Test() { cout << "Default ctor" << endl; }
  13. Test(const Test&) { cout << "Copy ctor" << endl; }
  14. Test(Test&&) { cout << "Move ctor" << endl; }
  15. Test& operator=(const Test&) { cout << "Copy assign" << endl; }
  16. Test& operator=(Test&&) { cout << "Move assign" << endl; }
  17. ~Test() { cout << "Destructor" << endl; }
  18. };
  19.  
  20. Test test_lvalue;
  21. std::string dummy("test");
  22.  
  23. std::string someStringFunc()
  24. {
  25. return "someStringFunc";
  26. }
  27.  
  28. void func(bool condition) {
  29. Test test = condition ? test_lvalue : Test();
  30. std::string dummy2 = condition ? dummy : someStringFunc();
  31. }
  32.  
  33. int main() {
  34. cout << "Begin main()" << endl;
  35. func(true);
  36. cout << "End main()" << endl;
  37. }
  38.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty