i’m initializing and inserting into a list like so
_ARRAY_DETAIL* pAR = new _ARRAY_DETAIL;
pAR->sVar1 = 1;
pAR->nVar2 = 2;
m_SomeList.push_back(pAR);
i am trying to find and erase all from the list that contains the value 1, and then delete the pointer we created with new, is my example below doing both in a good, correct efficient way?
while(Iter != m_SomeList.end());
{
if((*Iter)->sVar1 == 1)
{
_ARRAY_DETAIL* pAR = *Iter;
Iter = m_SomeList.erase(Iter);
delete pAR; pAR = NULL;
}
Iter++;
}
as an alternative you could use
remove ifalthough what you have done seems fine.