fork download
  1. #include <iostream>
  2. struct loud
  3. {
  4. static int id;
  5. int mid = ++id;
  6. loud() { std::cout << "default ctor of " << mid << "\n"; }
  7. loud(loud const&) { std::cout << "copy ctor of " << mid << "\n"; }
  8. loud(loud&&) noexcept { std::cout << "move ctor of " << mid << "\n"; }
  9. ~loud() { std::cout << "dtor of " << mid << "\n"; }
  10. loud& operator =(loud const&) { std::cout << "copy assignment-op of " << mid << "\n"; }
  11. loud& operator =(loud&&) noexcept { std::cout << "move assignment-op of " << mid << "\n"; }
  12. };
  13. int loud::id = 0;
  14.  
  15. #include <vector>
  16. int main()
  17. {
  18. std::vector<loud> v(5);
  19. v.erase(v.begin());
  20. std::cout << "end of program\n";
  21. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
default ctor of 1
default ctor of 2
default ctor of 3
default ctor of 4
default ctor of 5
move assignment-op of 1
move assignment-op of 2
move assignment-op of 3
move assignment-op of 4
dtor of 5
end of program
dtor of 1
dtor of 2
dtor of 3
dtor of 4