How to control the chunk size of `std::deque` when

2019-04-24 17:18发布

问题:

When we insert a new element into a std::deque, it may allocate a new chunk to contain the element if the existing chunks are all full.

However, how does the implementation control the chunk size?

Is it possible for the user to control the chunk size? or it just depends on the implementation's choice, e.g. 4K or 8K?

回答1:

This is a chosen value of the implementation, and there is no control over it.

For example Microsoft choose values of 16 or smaller for the number of elements in a block. (Search for _DEQUESIZ).