[Off topic] Re: C++ arrays vs vectors

Joe Buck jbuck@synopsys.com
Thu Aug 27 21:34:00 GMT 1998


> | Several people, including Dr Stroustrup, recommended assuming contiguous
> | vectors anyway, and avoiding any hypothetical weird STL implementation
> | that does it differently (nobody knew of any in the real world).
> 
> A vector<> implementation that is not contiguous could have the advantage
> that when the vector needs to be enlarged, and a realloc() would cause a
> need for moving the data, then instead one doesn't need to move the
> existing data.

Right, but we already have a container with that property.  It is
called deque<>.  And yes, the SGI implementation enlarges it without
needing to duplicate all the elements.

Given this, I don't think there is a compelling reason to implement
vector<> that way.



More information about the Gcc mailing list