Christopher Woods wrote:
Daniel Gehriger wrote:
------------------- for (Coll::iterator it = col.begin(); it != col.end(); /* noop */) { Coll::value_type& o = *(it++); o.destroy(); } -------------------
Aren't you asking for trouble here? If the call into a member function of a contained object invalidates iterators of the container that holds it and you're in the process of iterating over that container and calling such a function, then how do you know that the new value for 'it' is still points to a valid address within the container itself?
-Chris
I wasn't precise enough: The call to the member function only invalidates the iterators pointing to the object. All other iterators remain valid. - Daniel -- View this message in context: http://www.nabble.com/BOOST_FOREACH-and-iterating-by-reference-tf3806531.htm... Sent from the Boost - Users mailing list archive at Nabble.com.