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);
Throws: length_error if n > max_size(), as well as any exceptions thrown by the allocator.
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();
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.
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, if n >= capacity() is true, there are no effects; otherwise, capacity() is reduced to no less than n.
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;
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);
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.
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]

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant