fork download
  1. #include <iostream>
  2. #include <list>
  3. #include <string>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. typedef list<string> List;
  8.  
  9. int main() {
  10. List lst{ string("a"), string("b"), string("c") };
  11. auto it = lst.begin();
  12. advance(it, 1);
  13.  
  14. // _M_next->_M_prev = _M_prev; _M_prev->_M_next = _M_next;
  15. it._M_node->_M_unhook();
  16.  
  17. delete static_cast<_List_node<string> *>(it._M_node);
  18.  
  19. for (auto &s : lst)
  20. cout << s << endl;
  21. }
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
a
c