From: Ross Smith (ross.s_at_[hidden])
Date: 2001-09-07 21:15:03
> I have an application where it would be convenient to
> use std::vector for a variety of purposes. However,
> most of the vectors are tiny, and the dynamic memory
> management overhead is significant.
> boost::array is generally a better fit, but then I have
> to keep track of the actual number of elements in a custom
> way (array::size() is a static function), and push_back()
> etc. are not available.
> What I really want is a type which looks just like
> vector, but uses a built-in array (on the stack) rather
> than new/delete. I see two choices:
> 1. Replicate std::vector based on boost::array.
> This does not seem very elegant...
> 2. provide a custom STL allocator for use with std::vector.
> After staring at Josuttis chapter 15 for a while
> I came to the preliminary conclusion that this
> approach will not work because the allocator
> necessarily has to do some kind of dynamic allocation.
> - Are the alternative approaches (or even solutions)?
> - Would a well worked out "array_vector" or "static_vector"
> be a useful addition to boost?
You might like to have a look at the policy-based vector class I
proposed a while ago:
-- Ross Smith .......................................... ross.s_at_[hidden] Ihug (Auckland, New Zealand) ................... http://www.ihug.co.nz/ Vs lbh pna ernq guvf, lbh'er ivbyngvat gur QZPN
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk