std::listmyList{1, 2, 3, 4, 5}; myList.erase(myList.begin());
std::listIn this example, the `erase()` function is used inside a loop to remove all even numbers from the list. The loop iterates through the list using an iterator, and if the current element is even, the `erase()` function is called to remove it from the list. Note that the iterator is updated to the next element after erasing the current element. Package library: C++ STL (Standard Template Library)myList{1, 2, 3, 4, 5}; for (auto it = myList.begin(); it != myList.end(); ) { if (*it % 2 == 0) { it = myList.erase(it); } else { ++it; } }