
On 26 August 2011 10:33, Michael Goldshteyn <mgoldshteyn@comcast.net> wrote:
Likewise, making the growth multiplier for vector configurable via a template argument would be the other boon in such a container library. These two features (deque page / block size and vector multiplier config) should have been part of the STL to begin with. How many times have library vendors tweaked these two items? Why not let the developer choose his constants / coefficients at the time of class template instantiation?
1. The problem is that template arguments change the type. Do you really want vector<int, std::allocator<int>, 2> to be a different type than vector<int, std::allocator<int>, 3>? 2. You want to be able to pass in floating point numbers to the multiplier (for instance, multipliers under the golden ratio allow a vector to reuse the holes it leaves in the heap). 3. In order to guarantee amortized O(1) push_back, you have to enforce that the multiplier is strictly > 1. There are, of course, ways to mitigate all of this. But it isn't clear that the added complexity is worth it. -- Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404