std::hive<T,Allocator>::clear
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) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/container/hive/clear