brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · d7379fc Raw
51 lines · c
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___VECTOR_ERASE_H10#define _LIBCPP___VECTOR_ERASE_H11 12#include <__algorithm/remove.h>13#include <__algorithm/remove_if.h>14#include <__config>15#include <__fwd/vector.h>16 17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#  pragma GCC system_header19#endif20 21_LIBCPP_PUSH_MACROS22#include <__undef_macros>23 24#if _LIBCPP_STD_VER >= 2025 26_LIBCPP_BEGIN_NAMESPACE_STD27 28template <class _Tp, class _Allocator, class _Up>29_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type30erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {31  auto __old_size = __c.size();32  __c.erase(std::remove(__c.begin(), __c.end(), __v), __c.end());33  return __old_size - __c.size();34}35 36template <class _Tp, class _Allocator, class _Predicate>37_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type38erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {39  auto __old_size = __c.size();40  __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end());41  return __old_size - __c.size();42}43 44_LIBCPP_END_NAMESPACE_STD45 46#endif // _LIBCPP_STD_VER >= 2047 48_LIBCPP_POP_MACROS49 50#endif // _LIBCPP___VECTOR_ERASE_H51