On Sat, 28 May 2011, Geoff McLane wrote: > Hi all, > > I read (everywhere) that a vector erase invalidates > all current iterators - see say - > http://www.cplusplus.com/reference/stl/vector/erase/ > so I really do not understand why genfans.cxx has lasted > so long like it is ;=(( > > When it does a - > tris.erase( t_current ); > it should reset the iterators. The small patch attached > does just that... > > Maybe somehow, on some platforms, the iterators are > 'correctly' adjusted, but certainly NOT in WIN32, and I > suspect the same in other platforms! > > I would respectfully request the attached patch be > applied soonest, unless there is some other reasoning > at play here. > > It certainly works better for me ;=)) And removes > another reason why fgfs-construct can abort > without apparent reason!
Hi Geoff, If I recall correctly (it is still before my morning coffee here :) vector::erase() returns a new iterator that you can use to continue the iteration, so the below should work for continuing the iteration: t_current = tris.erase( t_current ); t_last = tris.end(); However, if you have more iterators around (than t_current and t_last) that will need to be adjusted perhaps a full restart is warranted. Cheers, Anders -- --------------------------------------------------------------------------- Anders Gidenstam WWW: http://www.gidenstam.org/FlightGear/ ------------------------------------------------------------------------------ vRanger cuts backup time in half-while increasing security. With the market-leading solution for virtual backup and recovery, you get blazing-fast, flexible, and affordable data protection. Download your free trial now. http://p.sf.net/sfu/quest-d2dcopy1 _______________________________________________ Flightgear-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/flightgear-devel

