Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:53

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H
0011 #define _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H
0012 
0013 #include <__config>
0014 
0015 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0016 #  pragma GCC system_header
0017 #endif
0018 
0019 _LIBCPP_PUSH_MACROS
0020 #include <__undef_macros>
0021 
0022 _LIBCPP_BEGIN_NAMESPACE_STD
0023 
0024 template <class _Container, class _Predicate>
0025 _LIBCPP_HIDE_FROM_ABI typename _Container::size_type __libcpp_erase_if_container(_Container& __c, _Predicate& __pred) {
0026   typename _Container::size_type __old_size = __c.size();
0027 
0028   const typename _Container::iterator __last = __c.end();
0029   for (typename _Container::iterator __iter = __c.begin(); __iter != __last;) {
0030     if (__pred(*__iter))
0031       __iter = __c.erase(__iter);
0032     else
0033       ++__iter;
0034   }
0035 
0036   return __old_size - __c.size();
0037 }
0038 
0039 _LIBCPP_END_NAMESPACE_STD
0040 
0041 _LIBCPP_POP_MACROS
0042 
0043 #endif // _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H