Eric Niebler wrote:
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.
Yes, exactly. I wouldn't do that usually, but the collection is in fact a database table, and I use the iterators to access the records. Each record contains a field with the index of the next record (basically a singly-linked list). Destroying the record therefore invalidates the iterator pointing to the record. Pre-incrementing, however, works fine. A solution would be to cache all indices when accessing the collection, but I can't afford the overhead for this. Maybe this case is too specialized for Boost and doesn't warrant the inclusion of a BOOST_FOREACH_PRE macro in the library. - 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.