std::experi...e(std::list)(3)
π std::experi...e(std::list)(3) π
okay bestie, welcome to the C++ Standard Libary page for std::experimental::erase(std::list) β yes, that is literally the manual name up there, typo and all, and we are moving on with main-character energy π
β¨
π NAME π
std::experimental::erase(std::list) - std::experimental::erase(std::list)
β¨ Synopsis β¨
Defined in header <experimental/list>
template< class T, class A, class U > (library
fundamentals TS v2)
void erase( std::list<T, A>& c, const U& value );
Erases all elements that compare equal to value from the container. Equivalent to
c.remove_if([&](auto& elem) { return elem == value; });
π¦ Parameters π¦
cβ container from which to erasevalueβ value to be removed
β Complexity β
Linear. No cap, that is the whole vibe for this one β
πΈ Example πΈ
// Run this code
#include <experimental/list>
#include <iostream>
auto show = [](const auto& container)
{
for (auto e : container)
std::cout << e;
std::cout << '\n';
};
int main()
{
std::list<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
π Notes π
Unlike std::list::remove, this function template accepts heterogeneous types and does not force a conversion to the container's value type before invoking the == operator. That is the whole note, bestie β no extra lore, no invented side quests π«Ά
π See also π
removeβ removes elements satisfying specific criteriaremove_ifβ (function template)removeβ removes elements satisfying specific criteriaremove_ifβ (public member function ofstd::list<T,Allocator>)erase_if (std::list)β (library fundamentals 2 TS) erases all elements satisfying a predicate from astd::list(function template)
thatβs the whole page, bestie π«Ά source is http://cppreference.com, dated 2024.06.10, and itβs the std::experi...e(std::list)(3) manual page β 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