You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.2KB

  1. // <vector> -*- C++ -*-
  2. // Copyright (C) 2001-2020 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /*
  21. *
  22. * Copyright (c) 1994
  23. * Hewlett-Packard Company
  24. *
  25. * Permission to use, copy, modify, distribute and sell this software
  26. * and its documentation for any purpose is hereby granted without fee,
  27. * provided that the above copyright notice appear in all copies and
  28. * that both that copyright notice and this permission notice appear
  29. * in supporting documentation. Hewlett-Packard Company makes no
  30. * representations about the suitability of this software for any
  31. * purpose. It is provided "as is" without express or implied warranty.
  32. *
  33. *
  34. * Copyright (c) 1996
  35. * Silicon Graphics Computer Systems, Inc.
  36. *
  37. * Permission to use, copy, modify, distribute and sell this software
  38. * and its documentation for any purpose is hereby granted without fee,
  39. * provided that the above copyright notice appear in all copies and
  40. * that both that copyright notice and this permission notice appear
  41. * in supporting documentation. Silicon Graphics makes no
  42. * representations about the suitability of this software for any
  43. * purpose. It is provided "as is" without express or implied warranty.
  44. */
  45. /** @file include/vector
  46. * This is a Standard C++ Library header.
  47. */
  48. #ifndef _GLIBCXX_VECTOR
  49. #define _GLIBCXX_VECTOR 1
  50. #pragma GCC system_header
  51. #include <bits/stl_algobase.h>
  52. #if __cplusplus > 201703L
  53. # include <bits/stl_algo.h> // For remove and remove_if
  54. #endif // C++20
  55. #include <bits/allocator.h>
  56. #include <bits/stl_construct.h>
  57. #include <bits/stl_uninitialized.h>
  58. #include <bits/stl_vector.h>
  59. #include <bits/stl_bvector.h>
  60. #include <bits/range_access.h>
  61. #ifndef _GLIBCXX_EXPORT_TEMPLATE
  62. # include <bits/vector.tcc>
  63. #endif
  64. #ifdef _GLIBCXX_DEBUG
  65. # include <debug/vector>
  66. #endif
  67. #if __cplusplus >= 201703L
  68. namespace std _GLIBCXX_VISIBILITY(default)
  69. {
  70. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  71. namespace pmr {
  72. template<typename _Tp> class polymorphic_allocator;
  73. template<typename _Tp>
  74. using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
  75. } // namespace pmr
  76. # ifdef _GLIBCXX_DEBUG
  77. namespace _GLIBCXX_STD_C::pmr {
  78. template<typename _Tp>
  79. using vector
  80. = _GLIBCXX_STD_C::vector<_Tp, std::pmr::polymorphic_allocator<_Tp>>;
  81. } // namespace _GLIBCXX_STD_C::pmr
  82. # endif
  83. _GLIBCXX_END_NAMESPACE_VERSION
  84. } // namespace std
  85. #endif // C++17
  86. #if __cplusplus > 201703L
  87. namespace std _GLIBCXX_VISIBILITY(default)
  88. {
  89. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  90. #define __cpp_lib_erase_if 202002L
  91. template<typename _Tp, typename _Alloc, typename _Predicate>
  92. inline typename vector<_Tp, _Alloc>::size_type
  93. erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred)
  94. {
  95. const auto __osz = __cont.size();
  96. __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred),
  97. __cont.end());
  98. return __osz - __cont.size();
  99. }
  100. template<typename _Tp, typename _Alloc, typename _Up>
  101. inline typename vector<_Tp, _Alloc>::size_type
  102. erase(vector<_Tp, _Alloc>& __cont, const _Up& __value)
  103. {
  104. const auto __osz = __cont.size();
  105. __cont.erase(std::remove(__cont.begin(), __cont.end(), __value),
  106. __cont.end());
  107. return __osz - __cont.size();
  108. }
  109. _GLIBCXX_END_NAMESPACE_VERSION
  110. } // namespace std
  111. #endif // C++20
  112. #endif /* _GLIBCXX_VECTOR */