Boost logo

Boost Users :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2008-05-14 10:14:02


Igor R. <igor_rubinov_at_[hidden]> writes:

>> > The problem with this code is that you are returning a reference > to data that might be immediately invalidated. A push_back via > another thread can cause the referenced memory to no longer be valid.
> Does push_back() really invalidate iterators to *previous* vector elements?!

Yes: it might have to allocate a new chunk of memory for the vector, in which
case it will have to move all the existing elements to the new memory, and
free the old one.

Anthony

-- 
Anthony Williams            | Just Software Solutions Ltd
Custom Software Development | http://www.justsoftwaresolutions.co.uk
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net