24 May
2007
24 May
'07
7:31 p.m.
Daniel Gehriger wrote:
My I suggest an addition to BOOST_FOREACH ?
I happen to work with custom containers whose iterators are invalidated when certain member functions are called on the contained objects. So I typically use a loop pattern as follows:
------------------- for (Coll::iterator it = col.begin(); it != col.end(); /* noop */) { Coll::value_type& o = *(it++); o.destroy(); }
Are you saying that calling o.destroy() causes "it" to be invalidated? This is bad practice. If that's not the case, then vanilla FOREACH should meet your needs. Please correct me if I've misunderstood your situation. -- Eric Niebler Boost Consulting www.boost-consulting.com