P
Paras
Hi
What is the correct way to delete an element from STL list while
iterating through the list
list<A*> _ls;
A * a;
list<A*>::iterator si1;
for (si1=_ls.begin(); si1!=_ls.end();++si1) {
if ( (*si1)->check() ) {
a =(*si);
_ls.erase(si1);
/* Now this function will point pint si1 to next element. (no
invalidate) Now how to still continue with for loop which will be a
problem now ??? ..
*/
delete a;
}
}
What is the correct way to delete an element from STL list while
iterating through the list
list<A*> _ls;
A * a;
list<A*>::iterator si1;
for (si1=_ls.begin(); si1!=_ls.end();++si1) {
if ( (*si1)->check() ) {
a =(*si);
_ls.erase(si1);
/* Now this function will point pint si1 to next element. (no
invalidate) Now how to still continue with for loop which will be a
problem now ??? ..
*/
delete a;
}
}