07-20-2011, 10:48 PM
Better way to erase elements from a std::list? in c++ 2011
Code:
list<int> m_list;
// Fill list with int values...
// Find ints == 4 and erase them
auto it = m_list.begin();
if (*it == 4)
{
it = m_list.erase(it);
}
while (it != m_list.end())
{
++it;
if (*it == 4)
{
it = m_list.erase(it);
}0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
