AlgorithmΒΆ

Functions that, in the same spirit of the STL, complement the <algorithm> header.

template <typename T, typename Compare = stdc::less<T>, typename... Rest> constexpr bool is_sorted(T first, T second, Rest... rest)

Checks if the elements [first,second,rest...] are sorted in non-descending order according to the Compare criteria, which defaults to stdc::less<T>

template <typename Container> typename Container::iterator erase_remove(Container& container, typename Container::value_type const& value)

Removes all elements from container that are equal to value.

Post:The size() of the container is reduced by the number of elements that were removed
Returns:Past-the-end iterator after the elements are removed
template <typename Container, typename UnaryPredicate> typename Container::iterator erase_remove_if(Container& container, UnaryPredicate pred)

Removes all elements from container for which predicate pred returns true.

Parameters:
  • container – The container from which elements will be removed
  • pred – The predicate to be applied to all elements in the container
Post:

The size() of the container is reduced by the number of elements that were removed

Returns:

Past-the-end iterator after the elements are removed