libstdc++
|
00001 // <deque> -*- 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) 1997 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/deque 00052 * This is a Standard C++ Library header. 00053 */ 00054 00055 #ifndef _GLIBCXX_DEQUE 00056 #define _GLIBCXX_DEQUE 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_deque.h> 00068 #include <bits/range_access.h> 00069 #include <bits/deque.tcc> 00070 00071 #ifdef _GLIBCXX_DEBUG 00072 # include <debug/deque> 00073 #endif 00074 00075 #ifdef _GLIBCXX_PROFILE 00076 # include <profile/deque> 00077 #endif 00078 00079 #if __cplusplus >= 201703L 00080 namespace std _GLIBCXX_VISIBILITY(default) 00081 { 00082 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00083 namespace pmr 00084 { 00085 template<typename _Tp> class polymorphic_allocator; 00086 template<typename _Tp> 00087 using deque = std::deque<_Tp, polymorphic_allocator<_Tp>>; 00088 } // namespace pmr 00089 _GLIBCXX_END_NAMESPACE_VERSION 00090 } // namespace std 00091 #endif // C++17 00092 00093 #if __cplusplus > 201703L 00094 namespace std _GLIBCXX_VISIBILITY(default) 00095 { 00096 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00097 00098 #define __cpp_lib_erase_if 201900L 00099 00100 template<typename _Tp, typename _Alloc, typename _Predicate> 00101 inline typename deque<_Tp, _Alloc>::size_type 00102 erase_if(deque<_Tp, _Alloc>& __cont, _Predicate __pred) 00103 { 00104 const auto __osz = __cont.size(); 00105 __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred), 00106 __cont.end()); 00107 return __osz - __cont.size(); 00108 } 00109 00110 template<typename _Tp, typename _Alloc, typename _Up> 00111 inline typename deque<_Tp, _Alloc>::size_type 00112 erase(deque<_Tp, _Alloc>& __cont, const _Up& __value) 00113 { 00114 const auto __osz = __cont.size(); 00115 __cont.erase(std::remove(__cont.begin(), __cont.end(), __value), 00116 __cont.end()); 00117 return __osz - __cont.size(); 00118 } 00119 _GLIBCXX_END_NAMESPACE_VERSION 00120 } // namespace std 00121 #endif // C++20 00122 00123 #endif /* _GLIBCXX_DEQUE */