std::flat_multimap::clear(3)
okay so bestie, welcome to the std::flat_multimap::clear(3) page from the C++ Standard Libary π this one is short and sweet: it's the glow-up that wipes your whole flat_multimap clean β¨
π NAME π
std::flat_multimap::clear β std::flat_multimap::clear (yes bestie, the name is literally the name, iconic behavior π
)
πΈ Synopsis πΈ
void clear() noexcept; (since C++23)
Erases all elements from the container adaptor. After this call, size() returns zero.
Invalidates any references, pointers, and iterators referring to contained elements. π«Ά
π¦ Parameters π¦
(none)β not a single parameter, she takes zero arguments, periodt π
π Return value π
(none)β nothing comes back, she just clears and leaves β¨
π₯ Complexity π₯
Linear in the size of the container adaptor, i.e., the number of elements. So yeah, she's doing actual work in there, no cap π
π Example π
// Run this code
#include <iostream>
#include <string_view>
#include <flat_map>
void print_info(std::string_view rem, const std::flat_multimap<int, char>& v)
{
std::cout << rem << "{ ";
for (const auto& [key, value] : v)
std::cout << '[' << key << "]:" << value << ' ';
std::cout << "}\n";
std::cout << "Size=" << v.size() << '\n';
}
int main()
{
std::flat_multimap<int, char> container{{1, 'x'}, {2, 'y'}, {3, 'z'}};
print_info("Before clear: ", container);
container.clear();
print_info("After clear: ", container);
}
π€ Output π€
Before clear: { [1]:x [2]:y [3]:z }
Size=3
After clear: { }
Size=0
π See also π
eraseβ erases elements (public member function)
mwah π this cutie came from http://cppreference.com, version/date 2024.06.10, and it's the std::flat_multimap::clear(3) page. byeee π«Άπ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms