Boost logo

Boost :

From: Craig Hicks (hicks_at_[hidden])
Date: 2001-02-19 10:35:57


Hello,

I recently started using containers to help in writing image processing
software which must
be as fast as possible since it is used in a production line.

I found to my dismay that std::vector always initialized all the elements on
resize().
This turned out to be a big computation penalty. At least with "new[]", no
initialization
is performed if the class/structure has no constructors, but this appears
not to be
an option with std::vector. Likewise for destructors.
Using push_back() would could a size check on each access, so is not an good
option.
I wrote a template class (with an i/f which is a subset of std::vector's)
to get around this, but I wonder if I am missing something basic,
if perhaps there is an easy (no more than say 1 line of code) to make
std::vector
do the same thing?

Cheers,

Craig Hicks
Engineer
KGK Ltd. Tokyo Japan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk