fork(5) download
  1. #include <iostream>
  2.  
  3. //
  4. // 一時オブジェクトの寿命
  5. //
  6.  
  7. struct something { ~something() { std::cout << "destructor" << std::endl; } };
  8.  
  9. something func() { return {}; }
  10. int main()
  11. {
  12. something(); // instance of something is temporary object
  13. func(); // returned value of func() is rvalue
  14. 1; // literal
  15. std::cout << "=== main ===" << std::endl;
  16. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
destructor
destructor
=== main ===