File indexing completed on 2026-05-03 08:14:07
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___VECTOR_ERASE_H
0010 #define _LIBCPP___VECTOR_ERASE_H
0011
0012 #include <__algorithm/remove.h>
0013 #include <__algorithm/remove_if.h>
0014 #include <__config>
0015 #include <__fwd/vector.h>
0016
0017 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0018 # pragma GCC system_header
0019 #endif
0020
0021 _LIBCPP_PUSH_MACROS
0022 #include <__undef_macros>
0023
0024 #if _LIBCPP_STD_VER >= 20
0025
0026 _LIBCPP_BEGIN_NAMESPACE_STD
0027
0028 template <class _Tp, class _Allocator, class _Up>
0029 _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
0030 erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
0031 auto __old_size = __c.size();
0032 __c.erase(std::remove(__c.begin(), __c.end(), __v), __c.end());
0033 return __old_size - __c.size();
0034 }
0035
0036 template <class _Tp, class _Allocator, class _Predicate>
0037 _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
0038 erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
0039 auto __old_size = __c.size();
0040 __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end());
0041 return __old_size - __c.size();
0042 }
0043
0044 _LIBCPP_END_NAMESPACE_STD
0045
0046 #endif
0047
0048 _LIBCPP_POP_MACROS
0049
0050 #endif