Namespaces
Variants

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

From cppreference.com
 
 
 
 
void clear() noexcept;
(since C++26)

Erases all elements from the container. After this call, size() returns zero.

Invalidates any references, pointers, and iterators referring to contained elements.

Complexity

Linear in the size of the container, i.e., the number of elements.

Example

#include <hive>
#include <print>

int main()
{
    std::hive<int> v{1, 2, 3};
    std::println("Before clear: {}, size={}, capacity={}", v, v.size(), v.capacity());
    v.clear();
    std::println("After clear: {}, size={}, capacity={}", v, v.size(), v.capacity());
}

Possible output:

Before clear: [1, 2, 3], size=3, capacity=76
After clear: [], size=0, capacity=76

See also

erases elements
(public member function) [edit]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.