23 Containers library [containers]

23.3 Sequence containers [sequences]

23.3.9 Class template hive [hive]

23.3.9.3 Capacity [hive.capacity]

size_type capacity() const noexcept;
Returns: The total number of elements that *this can hold without requiring allocation of more element blocks.
Complexity: Constant.
void reserve(size_type n);
Effects: If n <= capacity() is true, there are no effects.
Otherwise increases capacity() by allocating reserved blocks.
Postconditions: capacity() >= n is true.
Throws: length_error if n > max_size(), as well as any exceptions thrown by the allocator.
Complexity: It does not change the size of the sequence and takes at most linear time in the number of reserved blocks allocated.
Remarks: All references, pointers, and iterators referring to elements in *this, as well as the past-the-end iterator, remain valid.
void shrink_to_fit();
Preconditions: T is Cpp17MoveInsertable into hive.
Effects: shrink_to_fit is a non-binding request to reduce capacity() to be closer to size().
[Note 1: 
The request is non-binding to allow latitude for implementation-specific optimizations.
— end note]
It does not increase capacity(), but may reduce capacity().
It may reallocate elements.
If capacity() is already equal to size(), there are no effects.
If an exception is thrown during allocation of a new element block, capacity() may be reduced and reallocation may occur.
Otherwise if an exception is thrown, the effects are unspecified.
Complexity: If reallocation happens, linear in the size of the sequence.
Remarks: If reallocation happens, the order of the elements in *this may change and all references, pointers, and iterators referring to the elements in *this, as well as the past-the-end iterator, are invalidated.
void trim_capacity() noexcept; void trim_capacity(size_type n) noexcept;
Effects: For the first overload, all reserved blocks are deallocated, and capacity() is reduced accordingly.
For the second overload, capacity() is reduced to no less than n.
Complexity: Linear in the number of reserved blocks deallocated.
Remarks: All references, pointers, and iterators referring to elements in *this, as well as the past-the-end iterator, remain valid.
constexpr hive_limits block_capacity_limits() const noexcept;
Returns: current-limits.
Complexity: Constant.
static constexpr hive_limits block_capacity_default_limits() noexcept;
Returns: A hive_limits struct with the min and max members set to the implementation's default limits.
Complexity: Constant.
static constexpr hive_limits block_capacity_hard_limits() noexcept;
Returns: A hive_limits struct with the min and max members set to the implementation's hard limits.
Complexity: Constant.
void reshape(hive_limits block_limits);
Preconditions: T is Cpp17MoveInsertable into hive.
Effects: For any active blocks not within the bounds of block_limits, the elements within those active blocks are reallocated to new or existing element blocks which are within the bounds.
Any element blocks not within the bounds of block_limits are deallocated.
If an exception is thrown during allocation of a new element block, capacity() may be reduced, reallocation may occur, and current-limits may be assigned a value other than block_limits.
Otherwise block_limits is assigned to current-limits.
If any other exception is thrown the effects are unspecified.
Postconditions: size() is unchanged.
Complexity: Linear in the number of element blocks in *this.
If reallocation happens, also linear in the number of elements reallocated.
Remarks: This operation may change capacity().
If reallocation happens, the order of the elements in *this may change.
Reallocation invalidates all references, pointers, and iterators referring to the elements in *this, as well as the past-the-end iterator.
[Note 2: 
If no reallocation happens, they remain valid.
— end note]