Namespaces
Variants
Actions

std::erase, std::erase_if(std::list)

From cppreference.com
< cpp‎ | container‎ | list
 
 
 
 
Defined in header <list>
(1)
template< class T, class Alloc, class U >

typename std::list<T, Alloc>::size_type

    erase( std::list<T, Alloc>& c, const U& value );
(since C++20)
(until C++26)
template< class T, class Alloc, class U = T >

constexpr typename std::list<T, Alloc>::size_type

    erase( std::list<T, Alloc>& c, const U& value );
(since C++26)
template< class T, class Alloc, class Pred >

typename std::list<T, Alloc>::size_type

    erase_if( std::list<T, Alloc>& c, Pred pred );
(2) (since C++20)
(constexpr since C++26)
1) Erases all elements that compare equal to value from the container c. Equivalent to return c.remove_if([&](const auto& elem) -> bool { return elem == value; });.
2) Erases all elements that satisfy the predicate pred from the container c. Equivalent to return c.remove_if(pred);.

Contents