Reputation: 683
Is there any way to change vector memory allocation strategy? using your own strategy instead of doubling vector size on resize.
(here a good explanation about memory allocation)
Upvotes: 1
Views: 305
Reputation: 238351
No. There is no standard way to affect the growth strategy of std::vector
.
At least, there is no guaranteed way to reduce the growth rate. You can use reserve
before the growth triggering element addition which effectively allows you to control the lower bound of the growth rate.
instead of doubling vector size on resize
That's not necessarily the strategy used by the vector implementation.
Upvotes: 2