std::experi...orward_list)(3)
π NAME π
okay so bestie, welcome to the std::experi...orward_list)(3) page from the C++ Standard Library manual. The whole mood is literally this, twice:
std::experimental::erase(std::forward_list) β std::experimental::erase(std::forward_list)
Yes, it says the name twice. That's the original page's energy, not me glitching. π
β¨ Synopsis β¨
Defined in header <experimental/forward_list>.
template< class T, class A, class U >
void erase( std::forward_list<T, A>& c, const U& value );
This is the (library fundamentals TS v2) version, and it erases all elements that compare equal to value from the container. It's equivalent to:
c.remove_if([&](auto& elem) { return elem == value; });
π Parameters π
cβ container from which to erasevalueβ value to be removed
π Complexity π
Linear. That's the official complexity, no cap. β¨
π Example π
// Run this code
#include <experimental/forward_list>
#include <iostream>
auto show = [](const auto& container)
{
for (auto e : container)
std::cout << e;
std::cout << '\n';
};
int main()
{
std::forward_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 π«Ά
Unlikestd::forward_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's the whole note, bestie. Lowkey important, fr fr. π¦
π See also π
removeβ removes elements satisfying specific criteriaremove_ifβ (function template)removeβ removes elements satisfying specific criteriaremove_ifβ (public member function ofstd::forward_list<T,Allocator>)erase_if (std::forward_list)(library fundamentals 2 TS) β erases all elements satisfying a predicate from astd::forward_list(function template)
source/version/date check: http://cppreference.com β’ 2024.06.10 β’ std::experi...orward_list)(3). That's the footer, bestie β now go forth and erase with main character energy. π
π
π¦ 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