Re: Saving pointers to std::vector data

Kevin Atkinson <[email protected]>
Newsgroups gmane.comp.gnu.aspell.devel
Message-ID <[email protected]>
On Sat, 27 Aug 2005, Gary Setter wrote:

> My recollection is that the addresses of object in standard
> template library container object are not guaranteed to stay
> valid. The
> class is suppose to be able to reallocate memory as it needs to.
> Can anyone here back me up on this?

For std::vector the address should remain valid as long as the size of the 
object is not changed.  Gcc and possible also VC std:vector never shrink 
so decreasing the size does not invalid address references into an object.  
It could be the case the with BCB shrinking an object causes a 
reallocation.   Other objects (including the string class) do not offer 
such a guarantee.

> My plan is to continue looking into this and I may submit a
> patch that eliminates the WordEntry intr field and replaces it
> with code that retrieves the data more directly. How I continue
> will be effected by your comments.

Please submit a patch.  I may suggest an alternate solution but I need to 
see your changes first.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.