it isn't even specified that this has to work for a list. "Iterators, pointers and references referring to elements removed by the function are invalidated." http://www.cplusplus.com/reference/list/list/erase/