1*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
2*700637cbSDimitry Andric //
3*700637cbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*700637cbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*700637cbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*700637cbSDimitry Andric //
7*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
8*700637cbSDimitry Andric
9*700637cbSDimitry Andric #ifndef _LIBCPP___VECTOR_ERASE_H
10*700637cbSDimitry Andric #define _LIBCPP___VECTOR_ERASE_H
11*700637cbSDimitry Andric
12*700637cbSDimitry Andric #include <__algorithm/remove.h>
13*700637cbSDimitry Andric #include <__algorithm/remove_if.h>
14*700637cbSDimitry Andric #include <__config>
15*700637cbSDimitry Andric #include <__fwd/vector.h>
16*700637cbSDimitry Andric
17*700637cbSDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18*700637cbSDimitry Andric # pragma GCC system_header
19*700637cbSDimitry Andric #endif
20*700637cbSDimitry Andric
21*700637cbSDimitry Andric _LIBCPP_PUSH_MACROS
22*700637cbSDimitry Andric #include <__undef_macros>
23*700637cbSDimitry Andric
24*700637cbSDimitry Andric #if _LIBCPP_STD_VER >= 20
25*700637cbSDimitry Andric
26*700637cbSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
27*700637cbSDimitry Andric
28*700637cbSDimitry Andric template <class _Tp, class _Allocator, class _Up>
29*700637cbSDimitry Andric _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
erase(vector<_Tp,_Allocator> & __c,const _Up & __v)30*700637cbSDimitry Andric erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
31*700637cbSDimitry Andric auto __old_size = __c.size();
32*700637cbSDimitry Andric __c.erase(std::remove(__c.begin(), __c.end(), __v), __c.end());
33*700637cbSDimitry Andric return __old_size - __c.size();
34*700637cbSDimitry Andric }
35*700637cbSDimitry Andric
36*700637cbSDimitry Andric template <class _Tp, class _Allocator, class _Predicate>
37*700637cbSDimitry Andric _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
erase_if(vector<_Tp,_Allocator> & __c,_Predicate __pred)38*700637cbSDimitry Andric erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
39*700637cbSDimitry Andric auto __old_size = __c.size();
40*700637cbSDimitry Andric __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end());
41*700637cbSDimitry Andric return __old_size - __c.size();
42*700637cbSDimitry Andric }
43*700637cbSDimitry Andric
44*700637cbSDimitry Andric _LIBCPP_END_NAMESPACE_STD
45*700637cbSDimitry Andric
46*700637cbSDimitry Andric #endif // _LIBCPP_STD_VER >= 20
47*700637cbSDimitry Andric
48*700637cbSDimitry Andric _LIBCPP_POP_MACROS
49*700637cbSDimitry Andric
50*700637cbSDimitry Andric #endif // _LIBCPP___VECTOR_ERASE_H
51