container icon indicating copy to clipboard operation
container copied to clipboard

Add support for stored_size option in static_vector and small_vector

Open Lastique opened this issue 1 year ago • 1 comments

Both static_vector and small_vector could benefit from supporting the stored_size option that is supported by the base vector container. static_vector and small_vector are usually used for small numbers of elements, and it makes sense to be able to use a smaller type to store the number of elements in the container.

Also, just as an additional idea, static_vector could automatically use a smaller size type depending on the magnitude of the specified capacity. But my main request is still the support for explicit stored_size option.

Lastique avatar Jul 08 '24 17:07 Lastique

BTW, there is a documentation bug:

https://github.com/boostorg/container/blob/3ed1c76efdce0585a4ff6f56fbca25e9559955ae/include/boost/container/options.hpp#L403

here it says stored_size is supported, but it actually is not:

https://github.com/boostorg/container/blob/3ed1c76efdce0585a4ff6f56fbca25e9559955ae/include/boost/container/options.hpp#L393-L394

stored_size is also not listed as supported in the QuickBook documentation.

Lastique avatar Jul 08 '24 18:07 Lastique

Thanks for the proposal. Implemented in commits https://github.com/boostorg/container/commit/13603d7de15d8b410743173664cd579d38e221a9 and https://github.com/boostorg/container/commit/af58c7d226553d52ebf10dba259d99d66936cd6c. To be released with Boost 1.87.

igaztanaga avatar Oct 12 '24 22:10 igaztanaga