This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [Off topic] Re: C++ arrays vs vectors
- To: carlo at runaway dot xs4all dot nl (Carlo Wood)
- Subject: Re: [Off topic] Re: C++ arrays vs vectors
- From: Joe Buck <jbuck at synopsys dot com>
- Date: Thu, 27 Aug 98 21:02:32 PDT
- Cc: egcs at cygnus dot com
> | 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.