fork download
  1. #include <list>
  2. #include <iostream>
  3.  
  4. struct A
  5. {
  6. A(int i) : I(i) {}
  7. ~A() { std::cout << I << std::endl; }
  8. int I;
  9. };
  10.  
  11. int main()
  12. {
  13. std::list<A> l;
  14. l.push_back(A(1));
  15. l.push_back(A(2));
  16. l.push_back(A(3));
  17.  
  18. std::cout << "clearing list" << std::endl;
  19. l.clear();
  20. }
  21.  
Success #stdin #stdout 0.02s 2856KB
stdin
Standard input is empty
stdout
1
2
3
clearing list
1
2
3