std::experi...std::vector)(3)
β¨ NAME β¨
okay bestie, real talk: this page is from the C++ Standard Libary manual β yes, Libary, that's how it's spelled, don't come for me β and the page handle is std::experi...std::vector)(3). The function is literally called std::experimental::erase(std::vector), and the one-line description is also std::experimental::erase(std::vector). Repetitive? Maybe. Iconic? Absolutely. π
π¦ Synopsis π¦
Defined in header <experimental/vector>.
template< class T, class A, class U > (library
fundamentals TS v2)
void erase( std::vector<T, A>& c, const U& value );
This one erases all elements that compare equal to value from the container. Equivalent to c.erase(std::remove(c.begin(), c.end(), value), c.end());. (Yes, the original has that lil period at the end of the code, I'm not gonna gaslight you about it. π)
πΈ Parameters πΈ
cβ container from which to erasevalueβ value to be removed
π₯ Complexity π₯
Linear. β that's it, that's the whole vibe check. π
π Example π
Run this code, bestie:
// Run this code
#include <experimental/vector>
#include <iostream>
auto show = [](const auto& container)
{
for (auto e : container)
std::cout << e;
std::cout << '\n';
};
int main()
{
std::vector<int> data{1, 1, 1, 4, 1, 1, 1, 2, 1, 1, 1};
show(data);
std::experimental::erase(data, 1);
show(data);
}
π Output: π
11141112111
42
π See also π
removeβ removes elements satisfying specific criteriaremove_ifβ (function template)erase_if (std::vector)β erases all elements satisfying a predicate from astd::vector;(library fundamentals 2 TS);(function template)
mwah π β source/version: http://cppreference.com, date: 2024.06.10. periodt. π«Ά
π¦ 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