On Mon, Jul 14, 2003 at 10:05:51PM +0300, Martin Vermeer wrote: > void BranchList::remove(string const & s) > { > List::iterator it = list.begin(); > List::iterator end = list.end(); > for (; it != end; it++) { > if (it->getBranch() == s) list.erase(it); > } > } >
Optically, this should be if (it->getBranch() == s) list.erase(it); Theoretically, I'd expect this to be undefined behaviour as 'it' is invalid after its 'pointee' is erased. Practically, there is a std::list<>::remove_if(Pred) somewhere. Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)