I want to make a function which moves items from one STL list to another if they match a certain condition.
This code is not the way to do it. The iterator will most lik
Erase returns an iterator pointing to the element after the erased one:
Erase
std::list::iterator it = myList.begin(); while (it != myList.end()) { if(myCondition(*it)) { myOtherList.push_back(*it); it = myList.erase(it); } else { ++it; } }