14fee23f9Smrg// <vector> -*- C++ -*- 24fee23f9Smrg 3*b1e83836Smrg// Copyright (C) 2001-2022 Free Software Foundation, Inc. 44fee23f9Smrg// 54fee23f9Smrg// This file is part of the GNU ISO C++ Library. This library is free 64fee23f9Smrg// software; you can redistribute it and/or modify it under the 74fee23f9Smrg// terms of the GNU General Public License as published by the 84fee23f9Smrg// Free Software Foundation; either version 3, or (at your option) 94fee23f9Smrg// any later version. 104fee23f9Smrg 114fee23f9Smrg// This library is distributed in the hope that it will be useful, 124fee23f9Smrg// but WITHOUT ANY WARRANTY; without even the implied warranty of 134fee23f9Smrg// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 144fee23f9Smrg// GNU General Public License for more details. 154fee23f9Smrg 164fee23f9Smrg// Under Section 7 of GPL version 3, you are granted additional 174fee23f9Smrg// permissions described in the GCC Runtime Library Exception, version 184fee23f9Smrg// 3.1, as published by the Free Software Foundation. 194fee23f9Smrg 204fee23f9Smrg// You should have received a copy of the GNU General Public License and 214fee23f9Smrg// a copy of the GCC Runtime Library Exception along with this program; 224fee23f9Smrg// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 234fee23f9Smrg// <http://www.gnu.org/licenses/>. 244fee23f9Smrg 254fee23f9Smrg/* 264fee23f9Smrg * 274fee23f9Smrg * Copyright (c) 1994 284fee23f9Smrg * Hewlett-Packard Company 294fee23f9Smrg * 304fee23f9Smrg * Permission to use, copy, modify, distribute and sell this software 314fee23f9Smrg * and its documentation for any purpose is hereby granted without fee, 324fee23f9Smrg * provided that the above copyright notice appear in all copies and 334fee23f9Smrg * that both that copyright notice and this permission notice appear 344fee23f9Smrg * in supporting documentation. Hewlett-Packard Company makes no 354fee23f9Smrg * representations about the suitability of this software for any 364d5abbe8Smrg * purpose. It is provided "as is" without express or implied warranty. 374fee23f9Smrg * 384fee23f9Smrg * 394fee23f9Smrg * Copyright (c) 1996 404fee23f9Smrg * Silicon Graphics Computer Systems, Inc. 414fee23f9Smrg * 424fee23f9Smrg * Permission to use, copy, modify, distribute and sell this software 434fee23f9Smrg * and its documentation for any purpose is hereby granted without fee, 444fee23f9Smrg * provided that the above copyright notice appear in all copies and 454fee23f9Smrg * that both that copyright notice and this permission notice appear 464fee23f9Smrg * in supporting documentation. Silicon Graphics makes no 474fee23f9Smrg * representations about the suitability of this software for any 484fee23f9Smrg * purpose. It is provided "as is" without express or implied warranty. 494fee23f9Smrg */ 504fee23f9Smrg 514fee23f9Smrg/** @file include/vector 524fee23f9Smrg * This is a Standard C++ Library header. 534fee23f9Smrg */ 544fee23f9Smrg 554fee23f9Smrg#ifndef _GLIBCXX_VECTOR 564fee23f9Smrg#define _GLIBCXX_VECTOR 1 574fee23f9Smrg 584fee23f9Smrg#pragma GCC system_header 594fee23f9Smrg 604fee23f9Smrg#include <bits/stl_algobase.h> 614fee23f9Smrg#include <bits/allocator.h> 624fee23f9Smrg#include <bits/stl_construct.h> 634fee23f9Smrg#include <bits/stl_uninitialized.h> 644fee23f9Smrg#include <bits/stl_vector.h> 654fee23f9Smrg#include <bits/stl_bvector.h> 66*b1e83836Smrg#include <bits/refwrap.h> 6748fb7bfaSmrg#include <bits/range_access.h> 684fee23f9Smrg 694fee23f9Smrg#ifndef _GLIBCXX_EXPORT_TEMPLATE 704fee23f9Smrg# include <bits/vector.tcc> 714fee23f9Smrg#endif 724fee23f9Smrg 734fee23f9Smrg#ifdef _GLIBCXX_DEBUG 744fee23f9Smrg# include <debug/vector> 754fee23f9Smrg#endif 764fee23f9Smrg 77181254a7Smrg#if __cplusplus >= 201703L 78181254a7Smrgnamespace std _GLIBCXX_VISIBILITY(default) 79181254a7Smrg{ 80181254a7Smrg_GLIBCXX_BEGIN_NAMESPACE_VERSION 81181254a7Smrg namespace pmr { 82181254a7Smrg template<typename _Tp> class polymorphic_allocator; 83181254a7Smrg template<typename _Tp> 84181254a7Smrg using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>; 85181254a7Smrg } // namespace pmr 86181254a7Smrg# ifdef _GLIBCXX_DEBUG 87181254a7Smrg namespace _GLIBCXX_STD_C::pmr { 88181254a7Smrg template<typename _Tp> 89181254a7Smrg using vector 90181254a7Smrg = _GLIBCXX_STD_C::vector<_Tp, std::pmr::polymorphic_allocator<_Tp>>; 91181254a7Smrg } // namespace _GLIBCXX_STD_C::pmr 92181254a7Smrg# endif 93181254a7Smrg_GLIBCXX_END_NAMESPACE_VERSION 94181254a7Smrg} // namespace std 95181254a7Smrg#endif // C++17 964fee23f9Smrg 97181254a7Smrg#if __cplusplus > 201703L 98181254a7Smrgnamespace std _GLIBCXX_VISIBILITY(default) 99181254a7Smrg{ 100181254a7Smrg_GLIBCXX_BEGIN_NAMESPACE_VERSION 101181254a7Smrg 102fb8a8121Smrg#define __cpp_lib_erase_if 202002L 103181254a7Smrg 104181254a7Smrg template<typename _Tp, typename _Alloc, typename _Predicate> 105*b1e83836Smrg _GLIBCXX20_CONSTEXPR 106181254a7Smrg inline typename vector<_Tp, _Alloc>::size_type 107181254a7Smrg erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred) 108181254a7Smrg { 109*b1e83836Smrg using namespace __gnu_cxx; 110*b1e83836Smrg _GLIBCXX_STD_C::vector<_Tp, _Alloc>& __ucont = __cont; 111181254a7Smrg const auto __osz = __cont.size(); 112*b1e83836Smrg const auto __end = __ucont.end(); 113*b1e83836Smrg auto __removed = std::__remove_if(__ucont.begin(), __end, 114*b1e83836Smrg __ops::__pred_iter(std::ref(__pred))); 115*b1e83836Smrg if (__removed != __end) 116*b1e83836Smrg { 117*b1e83836Smrg __cont.erase(__niter_wrap(__cont.begin(), __removed), 118181254a7Smrg __cont.end()); 119181254a7Smrg return __osz - __cont.size(); 120181254a7Smrg } 121181254a7Smrg 122*b1e83836Smrg return 0; 123*b1e83836Smrg } 124*b1e83836Smrg 125181254a7Smrg template<typename _Tp, typename _Alloc, typename _Up> 126*b1e83836Smrg _GLIBCXX20_CONSTEXPR 127181254a7Smrg inline typename vector<_Tp, _Alloc>::size_type 128181254a7Smrg erase(vector<_Tp, _Alloc>& __cont, const _Up& __value) 129181254a7Smrg { 130*b1e83836Smrg using namespace __gnu_cxx; 131*b1e83836Smrg _GLIBCXX_STD_C::vector<_Tp, _Alloc>& __ucont = __cont; 132181254a7Smrg const auto __osz = __cont.size(); 133*b1e83836Smrg const auto __end = __ucont.end(); 134*b1e83836Smrg auto __removed = std::__remove_if(__ucont.begin(), __end, 135*b1e83836Smrg __ops::__iter_equals_val(__value)); 136*b1e83836Smrg if (__removed != __end) 137*b1e83836Smrg { 138*b1e83836Smrg __cont.erase(__niter_wrap(__cont.begin(), __removed), 139181254a7Smrg __cont.end()); 140181254a7Smrg return __osz - __cont.size(); 141181254a7Smrg } 142*b1e83836Smrg 143*b1e83836Smrg return 0; 144*b1e83836Smrg } 145181254a7Smrg_GLIBCXX_END_NAMESPACE_VERSION 146181254a7Smrg} // namespace std 147181254a7Smrg#endif // C++20 148181254a7Smrg 149181254a7Smrg#endif /* _GLIBCXX_VECTOR */ 150