This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Containers: assignment, construction from
- To: Anjul <anjul at cyberspace dot org>
- Subject: Re: Containers: assignment, construction from
- From: Gerald Pfeifer <pfeifer at dbai dot tuwien dot ac dot at>
- Date: Fri, 18 Feb 2000 17:04:27 +0100 (MET)
- cc: "Morrow, Mal" <mal dot morrow at intec dot co dot za>, duret_g at epita dot fr, gcc at gcc dot gnu dot org
On Fri, 18 Feb 2000, Anjul wrote:
> Is there a better list to post this question to?
Use one of the C++ newsgroups, but have a look at the documentation at
http://www.sgi.com/Technology/STL/ first, there's lot of interesting
stuff.
> The reason I prefer this is to avoid needless construction of blank
> elements in the first case. Yes, I could create a vector of size 0 and
> use a back_inserter as an argument to the copy command, but then, I
> may run into repeated "reallocs" (extensions), some of which may
> necessiate copying the entire vector.
You want to use vector<>::reserve().
Gerald
--
Gerald "Jerry" pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/