fork download
  1. #include <iostream>
  2.  
  3. struct Object
  4. {
  5. Object(int) { std::cout << "1\n"; }
  6. Object(int, int, int) { std::cout << "3\n"; }
  7. Object(const Object&) = delete;
  8. Object& operator=(const Object&) = delete;
  9. ~Object() { std::cout << "kthxbye\n"; }
  10. };
  11.  
  12. void foo(bool condition)
  13. {
  14. Object&& a = condition ? Object(1) : Object(2, 3, 4);
  15. std::cout << "end of foo\n";
  16. }
  17.  
  18. int main()
  19. {
  20. foo(true);
  21. foo(false);
  22. }
  23.  
Success #stdin #stdout 0s 2928KB
stdin
Standard input is empty
stdout
1
end of foo
kthxbye
3
end of foo
kthxbye