Namespaces
Variants

std::hive<T,Allocator>::reshape

From cppreference.com
 
 
 
 
void reshape( std::hive_limits block_limits );
(since C++26)

Reallocates elements within each active block that is not within the bounds of block_limits. The elements are moved to new or existing element blocks which are within the bounds.

Deallocates any element blocks not within the bounds of block_limits.

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 result is unspecified.

This function does not change the size(), but may change the capacity(). If reallocation happens, the order of the elements in *this may change.

Reallocation invalidates all references, pointers, and iterators (including end()) referring to the elements in *this. If no reallocation happens, they remain valid.

Parameters

block_limits - new block capacity limits
Type requirements
-
T must be MoveInsertable into std::hive. Otherwise, the behavior is undefined.

Exceptions

Any exception thrown during allocation of a new element block (typically std::bad_alloc) and during construction of an element.

Complexity

Linear in the number of element blocks in *this. If reallocation happens, also linear in the number of reallocated elements.

Example

See also

reduces memory usage by freeing unused memory
(public member function) [edit]
deallocates reserved blocks and reduces capacity accordingly
(public member function) [edit]
returns the number of elements that can be held in currently allocated storage
(public member function) [edit]
returns current block capacity limits
(public member function) [edit]