Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#12273 closed Feature Requests (fixed)

boost::container::static_vector max_size() and capacity() should be constant expressions

Reported by: jim.king@… 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 Ion Gaztañaga, 6 years ago

Resolution: fixed
Status: newclosed

Thanks for the request. Constant "static_capacity" has been added to static_vector/small_vector in commit:

https://github.com/boostorg/container/commit/4122e722a4b43cfcd8a2b29b3cc02209564b2fbf

comment:2 by jking@…, 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 anonymous, 6 years ago

Milestone: To Be DeterminedBoost 1.63.0

comment:4 by anonymous, 6 years ago

Milestone: Boost 1.63.0Boost 1.62.0
Note: See TracTickets for help on using tickets.