Deleting an element from a list in a loop
- From: "Andrew Chalk" <achalk@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 30 Aug 2006 00:09:09 -0500
Will deleting an element from a list while iterating through a loop mess up
the internal pointers? I am thinking of a construct such as this where I
call erase() in the loop:
for (;it != m_list.end(); it++) {
if ((*it)->ThreadFinished() == true) {
...DO STUFF
m_list.erase(it); // delete the element from the list
// Do we need to break out of the loop here?
}
}
Many thanks,
.
- Follow-Ups:
- Re: Deleting an element from a list in a loop
- From: Doug Harrison [MVP]
- Re: Deleting an element from a list in a loop
- Prev by Date: Re: Error C2535 With vector ("member function already defined")
- Next by Date: Re: Deleting an element from a list in a loop
- Previous by thread: MSVC2005: problem with valarray<valarray<T> >
- Next by thread: Re: Deleting an element from a list in a loop
- Index(es):
Relevant Pages
|