#12273 closed Feature Requests (fixed)
boost::container::static_vector max_size() and capacity() should be constant expressions
Reported by: | Owned by: | Ion Gaztañaga | |
---|---|---|---|
Milestone: | Boost 1.62.0 | Component: | container |
Version: | Boost 1.61.0 | Severity: | Optimization |
Keywords: | Cc: |
Description
The capacity of a static_vector is a compile time constant. One should be able to retrieve the capacity at compile time as a constant expression. In the current implementation, one must execute a runtime method of either capacity() or max_size() to obtain the capacity. There are use cases where one would want to create another container that has the same capacity as the static_vector will have, so to improve ease of use I would propose adding:
BOOST_STATIC_CONSTANT(size_type, capacity = Capacity) BOOST_STATIC_CONSTANT(size_type, max_size = Capacity)
following the set of typedefs in the class.
Change History (4)
comment:1 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 6 years ago
According to the pull request this is in the 1.62 tag - the milestone for this issue needs to be updated to indicate that.
comment:3 by , 6 years ago
Milestone: | To Be Determined → Boost 1.63.0 |
---|
comment:4 by , 6 years ago
Milestone: | Boost 1.63.0 → Boost 1.62.0 |
---|
Thanks for the request. Constant "static_capacity" has been added to static_vector/small_vector in commit:
https://github.com/boostorg/container/commit/4122e722a4b43cfcd8a2b29b3cc02209564b2fbf