std::multiset::clear(3)
πΈ NAME πΈ
Okay so, bestie, this is std::multiset::clear(3) from the C++ Standard Libary manual, section 3, and the NAME line is lowkey just std::multiset::clear - std::multiset::clear β which is giving βI am the moment, I am the brandβ πβ¨
β¨ Synopsis β¨
void clear(); (noexcept since C++11)
It erases all elements from the container. After this call, size() returns zero. Periodt π
It also invalidates any references, pointers, and iterators referring to contained elements. Any past-the-end iterator remains valid. So likeβ¦ the end iterator is safe, but the element-havers are NOT π
π Parameters π
(none) β it takes absolutely nothing, she works alone, main character energy fr fr π¦
π«Ά Return value π«Ά
(none) β also nothing. No return, no drama, just vibes and deletion π
π₯ Complexity π₯
Linear in the size of the container, i.e., the number of elements. Thatβs the whole complexity tea ββ¨
π¬ Example π¬
Run this code, bestie:
// Run this code
#include <iostream>
#include <string_view>
#include <set>
void print_info(std::string_view rem, const std::multiset<int>& v)
{
std::cout << rem << "{ ";
for (const auto& value : v)
std::cout << value << ' ';
std::cout << "}\n";
std::cout << "Size=" << v.size() << '\n';
}
int main()
{
std::multiset<int> container{1, 2, 3};
print_info("Before clear: ", container);
container.clear();
print_info("After clear: ", container);
}
π€ Output π€
Before clear: { 1 2 3 }
Size=3
After clear: { }
Size=0
Not the size going from 3 to 0 π she really said βclearβ and cleared π
β¨
π Defect reports π
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR: LWG 224 Β· Applied to: C++98 Β· Behavior as published: the complexity was
log(size()) + N, butNwas not defined Β· Correct behavior: corrected to'linear in size()'π«Ά
π See also π
eraseβ erases elements (public member function) π§
Source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::multiset::clear(3) β okay bye bestie, stay slaying and keep those past-the-end iterators valid ππβ¨
π¦ 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