From: Manuel M. <mm...@ce...> - 2008-07-03 15:49:18
|
To Bob: > Try compiling with -gstabs, that's what I have to do with the sjlj > compiler. The debug information doesn't work otherwise. YES, YES, YES. God exists. Thank you never enough. To Giel >> pENu::~pENu() >> { >> std::list <lQ*>::iterator iterL; >> iterL = aLiQu->begin(); >> while ( iterL != aLiQu->end() ) >> { delete (*iterL); >> iterL = aLiQu->begin(); >> } >> } > > On a less related side note. That code ^^ will produce an infinite loop. > Which is because you delete the objects pointed to by the pointers from > your container, but you don't advance the iterator to the next pointer > in the container. > > You'll need to call the ++ operator on your iterator to advance to the > next element in the container. Thus something like this would loop over > all elements properly (without looping infinitely): What I didn't tell is that (*iterL) dtor modifies aLiQu list, removing itself from it. So, I just set iterL again to aLiQu->begin(). When all elements are deleted, aLiQu is empty and so iterL==aLiQu->end() and loop finishes. Manolo |