libstdc++
|
00001 // <vector> -*- C++ -*- 00002 00003 // Copyright (C) 2001-2019 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /* 00026 * 00027 * Copyright (c) 1994 00028 * Hewlett-Packard Company 00029 * 00030 * Permission to use, copy, modify, distribute and sell this software 00031 * and its documentation for any purpose is hereby granted without fee, 00032 * provided that the above copyright notice appear in all copies and 00033 * that both that copyright notice and this permission notice appear 00034 * in supporting documentation. Hewlett-Packard Company makes no 00035 * representations about the suitability of this software for any 00036 * purpose. It is provided "as is" without express or implied warranty. 00037 * 00038 * 00039 * Copyright (c) 1996 00040 * Silicon Graphics Computer Systems, Inc. 00041 * 00042 * Permission to use, copy, modify, distribute and sell this software 00043 * and its documentation for any purpose is hereby granted without fee, 00044 * provided that the above copyright notice appear in all copies and 00045 * that both that copyright notice and this permission notice appear 00046 * in supporting documentation. Silicon Graphics makes no 00047 * representations about the suitability of this software for any 00048 * purpose. It is provided "as is" without express or implied warranty. 00049 */ 00050 00051 /** @file include/vector 00052 * This is a Standard C++ Library header. 00053 */ 00054 00055 #ifndef _GLIBCXX_VECTOR 00056 #define _GLIBCXX_VECTOR 1 00057 00058 #pragma GCC system_header 00059 00060 #include <bits/stl_algobase.h> 00061 #if __cplusplus > 201703L 00062 # include <bits/stl_algo.h> // For remove and remove_if 00063 #endif // C++20 00064 #include <bits/allocator.h> 00065 #include <bits/stl_construct.h> 00066 #include <bits/stl_uninitialized.h> 00067 #include <bits/stl_vector.h> 00068 #include <bits/stl_bvector.h> 00069 #include <bits/range_access.h> 00070 00071 #ifndef _GLIBCXX_EXPORT_TEMPLATE 00072 # include <bits/vector.tcc> 00073 #endif 00074 00075 #ifdef _GLIBCXX_DEBUG 00076 # include <debug/vector> 00077 #endif 00078 00079 #ifdef _GLIBCXX_PROFILE 00080 # include <profile/vector> 00081 #endif 00082 00083 #if __cplusplus >= 201703L 00084 namespace std _GLIBCXX_VISIBILITY(default) 00085 { 00086 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00087 namespace pmr { 00088 template<typename _Tp> class polymorphic_allocator; 00089 template<typename _Tp> 00090 using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>; 00091 } // namespace pmr 00092 # ifdef _GLIBCXX_DEBUG 00093 namespace _GLIBCXX_STD_C::pmr { 00094 template<typename _Tp> 00095 using vector 00096 = _GLIBCXX_STD_C::vector<_Tp, std::pmr::polymorphic_allocator<_Tp>>; 00097 } // namespace _GLIBCXX_STD_C::pmr 00098 # endif 00099 _GLIBCXX_END_NAMESPACE_VERSION 00100 } // namespace std 00101 #endif // C++17 00102 00103 #if __cplusplus > 201703L 00104 namespace std _GLIBCXX_VISIBILITY(default) 00105 { 00106 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00107 00108 #define __cpp_lib_erase_if 201900L 00109 00110 template<typename _Tp, typename _Alloc, typename _Predicate> 00111 inline typename vector<_Tp, _Alloc>::size_type 00112 erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred) 00113 { 00114 const auto __osz = __cont.size(); 00115 __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred), 00116 __cont.end()); 00117 return __osz - __cont.size(); 00118 } 00119 00120 template<typename _Tp, typename _Alloc, typename _Up> 00121 inline typename vector<_Tp, _Alloc>::size_type 00122 erase(vector<_Tp, _Alloc>& __cont, const _Up& __value) 00123 { 00124 const auto __osz = __cont.size(); 00125 __cont.erase(std::remove(__cont.begin(), __cont.end(), __value), 00126 __cont.end()); 00127 return __osz - __cont.size(); 00128 } 00129 _GLIBCXX_END_NAMESPACE_VERSION 00130 } // namespace std 00131 #endif // C++20 00132 00133 #endif /* _GLIBCXX_VECTOR */