fork(1) download
  1. #include <iostream>
  2.  
  3. struct reporting {
  4. reporting() { std::cout << "Constructed" << std::endl;}
  5. ~reporting() { std::cout << "Destructed" << std::endl;}
  6. reporting(reporting const&) { std::cout << "Copy-Constructed" << std::endl;}
  7. reporting(reporting &&) { std::cout << "Move-Constructed" << std::endl;}
  8. reporting & operator=(reporting const&) { std::cout << "Copy-Assigned" << std::endl; return *this;}
  9. reporting & operator=(reporting &&) { std::cout << "Move-Assigned" << std::endl; return *this;}
  10.  
  11. void print() const {std::cout << "printing." << std::endl;}
  12. };
  13.  
  14. const reporting& get_or(const reporting& def)
  15. {
  16. return def;
  17. }
  18.  
  19. int main()
  20. {
  21. const reporting& foo = get_or(reporting{});
  22.  
  23. foo.print();
  24. return 0;
  25. }
Success #stdin #stdout 0s 16048KB
stdin
Standard input is empty
stdout
Constructed
Destructed
printing.