Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-03-06 16:44:27

----- Original Message -----
From: "Stewart, Robert" <stewart_at_[hidden]>

> The memory for the vector is not reallocated, and the elements are not
> copied from the old to a new allocation. That is, with a judicious
call to
> reserve() before push_back(), size() < capacity() will always be true,
so x
> will be copied into the uninitialized memory at end() and the size
will be
> incremented. Thus, there is no memory/copy performance penalty which
> what I thought "slow" was meant to imply. If a comparison of two
> and the increment of another is more overhead than you can bear --
though it
> certainly doesn't justify the label "slow"! -- then you need a
> array such as a C array or a wrapper class of a C array.

You don't /need/ plain C arrays to avoid the checks for each element;
that's what insert(pos, start, finish) and resize(n, x) are for.

On huge vectors of complex<>, even the member initializations in the
complex<> constructor are too expensive, however.


Boost list run by bdawes at, gregod at, cpdaniel at, john at