xref: /netbsd-src/external/gpl3/gcc.old/dist/libstdc++-v3/include/std/vector (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
11debfc3dSmrg// <vector> -*- C++ -*-
21debfc3dSmrg
3*8feb0f0bSmrg// Copyright (C) 2001-2020 Free Software Foundation, Inc.
41debfc3dSmrg//
51debfc3dSmrg// This file is part of the GNU ISO C++ Library.  This library is free
61debfc3dSmrg// software; you can redistribute it and/or modify it under the
71debfc3dSmrg// terms of the GNU General Public License as published by the
81debfc3dSmrg// Free Software Foundation; either version 3, or (at your option)
91debfc3dSmrg// any later version.
101debfc3dSmrg
111debfc3dSmrg// This library is distributed in the hope that it will be useful,
121debfc3dSmrg// but WITHOUT ANY WARRANTY; without even the implied warranty of
131debfc3dSmrg// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
141debfc3dSmrg// GNU General Public License for more details.
151debfc3dSmrg
161debfc3dSmrg// Under Section 7 of GPL version 3, you are granted additional
171debfc3dSmrg// permissions described in the GCC Runtime Library Exception, version
181debfc3dSmrg// 3.1, as published by the Free Software Foundation.
191debfc3dSmrg
201debfc3dSmrg// You should have received a copy of the GNU General Public License and
211debfc3dSmrg// a copy of the GCC Runtime Library Exception along with this program;
221debfc3dSmrg// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
231debfc3dSmrg// <http://www.gnu.org/licenses/>.
241debfc3dSmrg
251debfc3dSmrg/*
261debfc3dSmrg *
271debfc3dSmrg * Copyright (c) 1994
281debfc3dSmrg * Hewlett-Packard Company
291debfc3dSmrg *
301debfc3dSmrg * Permission to use, copy, modify, distribute and sell this software
311debfc3dSmrg * and its documentation for any purpose is hereby granted without fee,
321debfc3dSmrg * provided that the above copyright notice appear in all copies and
331debfc3dSmrg * that both that copyright notice and this permission notice appear
341debfc3dSmrg * in supporting documentation.  Hewlett-Packard Company makes no
351debfc3dSmrg * representations about the suitability of this software for any
361debfc3dSmrg * purpose.  It is provided "as is" without express or implied warranty.
371debfc3dSmrg *
381debfc3dSmrg *
391debfc3dSmrg * Copyright (c) 1996
401debfc3dSmrg * Silicon Graphics Computer Systems, Inc.
411debfc3dSmrg *
421debfc3dSmrg * Permission to use, copy, modify, distribute and sell this software
431debfc3dSmrg * and its documentation for any purpose is hereby granted without fee,
441debfc3dSmrg * provided that the above copyright notice appear in all copies and
451debfc3dSmrg * that both that copyright notice and this permission notice appear
461debfc3dSmrg * in supporting documentation.  Silicon Graphics makes no
471debfc3dSmrg * representations about the suitability of this software for any
481debfc3dSmrg * purpose.  It is provided "as is" without express or implied warranty.
491debfc3dSmrg */
501debfc3dSmrg
511debfc3dSmrg/** @file include/vector
521debfc3dSmrg *  This is a Standard C++ Library header.
531debfc3dSmrg */
541debfc3dSmrg
551debfc3dSmrg#ifndef _GLIBCXX_VECTOR
561debfc3dSmrg#define _GLIBCXX_VECTOR 1
571debfc3dSmrg
581debfc3dSmrg#pragma GCC system_header
591debfc3dSmrg
601debfc3dSmrg#include <bits/stl_algobase.h>
61c0a68be4Smrg#if __cplusplus > 201703L
62c0a68be4Smrg#  include <bits/stl_algo.h> // For remove and remove_if
63c0a68be4Smrg#endif // C++20
641debfc3dSmrg#include <bits/allocator.h>
651debfc3dSmrg#include <bits/stl_construct.h>
661debfc3dSmrg#include <bits/stl_uninitialized.h>
671debfc3dSmrg#include <bits/stl_vector.h>
681debfc3dSmrg#include <bits/stl_bvector.h>
691debfc3dSmrg#include <bits/range_access.h>
701debfc3dSmrg
711debfc3dSmrg#ifndef _GLIBCXX_EXPORT_TEMPLATE
721debfc3dSmrg# include <bits/vector.tcc>
731debfc3dSmrg#endif
741debfc3dSmrg
751debfc3dSmrg#ifdef _GLIBCXX_DEBUG
761debfc3dSmrg# include <debug/vector>
771debfc3dSmrg#endif
781debfc3dSmrg
79c0a68be4Smrg#if __cplusplus >= 201703L
80c0a68be4Smrgnamespace std _GLIBCXX_VISIBILITY(default)
81c0a68be4Smrg{
82c0a68be4Smrg_GLIBCXX_BEGIN_NAMESPACE_VERSION
83c0a68be4Smrg  namespace pmr {
84c0a68be4Smrg    template<typename _Tp> class polymorphic_allocator;
85c0a68be4Smrg    template<typename _Tp>
86c0a68be4Smrg      using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
87c0a68be4Smrg  } // namespace pmr
88c0a68be4Smrg# ifdef _GLIBCXX_DEBUG
89c0a68be4Smrg  namespace _GLIBCXX_STD_C::pmr {
90c0a68be4Smrg    template<typename _Tp>
91c0a68be4Smrg      using vector
92c0a68be4Smrg	= _GLIBCXX_STD_C::vector<_Tp, std::pmr::polymorphic_allocator<_Tp>>;
93c0a68be4Smrg  } // namespace _GLIBCXX_STD_C::pmr
94c0a68be4Smrg# endif
95c0a68be4Smrg_GLIBCXX_END_NAMESPACE_VERSION
96c0a68be4Smrg} // namespace std
97c0a68be4Smrg#endif // C++17
981debfc3dSmrg
99c0a68be4Smrg#if __cplusplus > 201703L
100c0a68be4Smrgnamespace std _GLIBCXX_VISIBILITY(default)
101c0a68be4Smrg{
102c0a68be4Smrg_GLIBCXX_BEGIN_NAMESPACE_VERSION
103c0a68be4Smrg
104*8feb0f0bSmrg#define __cpp_lib_erase_if 202002L
105c0a68be4Smrg
106c0a68be4Smrg  template<typename _Tp, typename _Alloc, typename _Predicate>
107c0a68be4Smrg    inline typename vector<_Tp, _Alloc>::size_type
108c0a68be4Smrg    erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred)
109c0a68be4Smrg    {
110c0a68be4Smrg      const auto __osz = __cont.size();
111c0a68be4Smrg      __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred),
112c0a68be4Smrg		   __cont.end());
113c0a68be4Smrg      return __osz - __cont.size();
114c0a68be4Smrg    }
115c0a68be4Smrg
116c0a68be4Smrg  template<typename _Tp, typename _Alloc, typename _Up>
117c0a68be4Smrg    inline typename vector<_Tp, _Alloc>::size_type
118c0a68be4Smrg    erase(vector<_Tp, _Alloc>& __cont, const _Up& __value)
119c0a68be4Smrg    {
120c0a68be4Smrg      const auto __osz = __cont.size();
121c0a68be4Smrg      __cont.erase(std::remove(__cont.begin(), __cont.end(), __value),
122c0a68be4Smrg		   __cont.end());
123c0a68be4Smrg      return __osz - __cont.size();
124c0a68be4Smrg    }
125c0a68be4Smrg_GLIBCXX_END_NAMESPACE_VERSION
126c0a68be4Smrg} // namespace std
127c0a68be4Smrg#endif // C++20
128c0a68be4Smrg
129c0a68be4Smrg#endif /* _GLIBCXX_VECTOR */
130