
On Oct 4, 2005, at 1:37 AM, Ian McCulloch wrote:
Boris wrote:
"Pavel Vozenilek" <pavel_vozenilek@hotmail.com>,
How would such dynamic_array be better (different) than std::vector?
I wouldn't say it's better. It would be just a bit more suitable in a situation where you know that you will deal with a fixed number of elements at runtime. The interface would be probably similar to std::vector but without inserting/removing operations. While std::vector is the natural choice when you need a dynamic array and boost::array when you know the (fixed) size at compile time this new array type (whatever the name would be) would be chosen when you know the (fixed) size only at runtime.
You still have not stated what advantages such a container would have over a resizable container. In other words, if you omit the resize() et. al. from std::vector, what extra functionality can be gained in return?
I see advantages in a variant of this idea, with a compile-time fixed capacity, an implementation of which was done a few years ago by Synge Todo and posted here. There the advantage is that pointer dereferencing can be avoided, and memory usage is minimized. Discussions of this library stopped on the Boost list, after some members wanted a full-fledged policy-based vector instead, which was then never developed. For those who need it, the library is now published under the Boost license as a part of the ALPS libraries (http://alps.comp-phys.org/). It would be worth reconsidering this project, and maybe extending it. Matthias