fork(2) download
  1. #include <iostream>
  2. #include <utility>
  3. using namespace std;
  4.  
  5. struct LogMe {
  6. std::string member;
  7.  
  8. LogMe() {
  9. cout << __FUNCTION__ << " - def.ctor!" << endl;
  10. }
  11. ~LogMe() {
  12. cout << __FUNCTION__ << " - dtor!" << endl;
  13. }
  14. LogMe(LogMe const&) {
  15. cout << __FUNCTION__ << " - cpy.ctor!" << endl;
  16. }
  17. LogMe& operator=(LogMe const&) {
  18. cout << __FUNCTION__ << " - cpy.assign.op!" << endl;
  19. return *this;
  20. }
  21. LogMe(LogMe&&) {
  22. cout << __FUNCTION__ << " - move.ctor!" << endl;
  23. }
  24. LogMe& operator=(LogMe&&) {
  25. cout << __FUNCTION__ << " - move.assign.op!" << endl;
  26. return *this;
  27. }
  28. };
  29.  
  30. int main() {
  31. cout << "# Construct Object via auto obj = ...\n";
  32. auto obj = LogMe();
  33. cout << "# Construct pair<int, object> via auto objp = ...\n";
  34. auto objp = pair<int, LogMe>();
  35. cout << "# Construct pair<int, object> via pair objp2; ...\n";
  36. pair<int, LogMe> p2;
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
# Construct Object via auto obj = ...
LogMe - def.ctor!
# Construct pair<int, object> via auto objp = ...
LogMe - def.ctor!
# Construct pair<int, object> via pair objp2; ...
LogMe - def.ctor!
~LogMe - dtor!
~LogMe - dtor!
~LogMe - dtor!