std::forward_list::remove, std::forward_list::remove_if

From Cppreference

Jump to: navigation, search
void remove( const T& value );
(C++11 feature)
template< class UnaryPredicate >
void remove_if( UnaryPredicate p );
(C++11 feature)

Removes all elements satisfying specific criteria. The first version removes all elements that are equal to value, the second version removes all elements for which predicate p returns true.


Contents

[edit] Parameters

value - value of the elements to remove
p - unary predicate which returns ​true if the element should be removed.

The signature of the predicate function should be equivalent to the following:

bool pred(const Type &a);

The signature does not need to have const &, but the function must not modify the objects passed to it.
The type Type must be such that an object of type forward_list<T,Allocator>::const_iterator can be dereferenced and then implicitly converted to Type. ​

[edit] Return value

(none)

[edit] Example

[edit] Complexity

linear in the size of the container