aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Smith-Rowland <3dw4rd@verizon.net>2018-11-28 16:44:25 +0000
committerEdward Smith-Rowland <emsr@gcc.gnu.org>2018-11-28 16:44:25 +0000
commit188588e443008dd7795947db60b68571ed724fe3 (patch)
tree96fe0d3f6fb7bc21979a5fdd0f037799009014d8
parentbd6ccc290a624a54f779054205cbfabb4e33a0aa (diff)
downloadgcc-188588e443008dd7795947db60b68571ed724fe3.zip
gcc-188588e443008dd7795947db60b68571ed724fe3.tar.gz
gcc-188588e443008dd7795947db60b68571ed724fe3.tar.bz2
Implement uniform container erasure for C++20.
2018-11-28 Edward Smith-Rowland <3dw4rd@verizon.net> Implement uniform container erasure for C++20. * include/Makefile.am: Move erase_if.h. * include/Makefile.in: Move erase_if.h. * include/experimental/bits/erase_if.h: Move ... * include/bits/erase_if.h: ... here. * include/experimental/map: Move erase_if.h. * include/experimental/set: Move erase_if.h. * include/experimental/unordered_map: Move erase_if.h. * include/experimental/unordered_set: Move erase_if.h. * include/std/deque (erase_if, erase): New functions. * include/std/forward_list: Ditto. * include/std/list: Ditto. * include/std/map: Ditto. * include/std/set: Ditto. * include/std/string: Ditto. * include/std/unordered_map: Ditto. * include/std/unordered_set: Ditto. * include/std/vector: Ditto. * testsuite/21_strings/basic_string/erasure.cc: New test. * testsuite/23_containers/deque/erasure.cc: New test. * testsuite/23_containers/forward_list/erasure.cc: New test. * testsuite/23_containers/list/erasure.cc: New test. * testsuite/23_containers/map/erasure.cc: New test. * testsuite/23_containers/set/erasure.cc: New test. * testsuite/23_containers/unordered_map/erasure.cc: New test. * testsuite/23_containers/unordered_set/erasure.cc: New test. * testsuite/23_containers/vector/erasure.cc: New test. From-SVN: r266567
-rw-r--r--libstdc++-v3/ChangeLog30
-rw-r--r--libstdc++-v3/include/Makefile.am2
-rw-r--r--libstdc++-v3/include/Makefile.in2
-rw-r--r--libstdc++-v3/include/bits/erase_if.h (renamed from libstdc++-v3/include/experimental/bits/erase_if.h)17
-rw-r--r--libstdc++-v3/include/experimental/map6
-rw-r--r--libstdc++-v3/include/experimental/set6
-rw-r--r--libstdc++-v3/include/experimental/unordered_map6
-rw-r--r--libstdc++-v3/include/experimental/unordered_set6
-rw-r--r--libstdc++-v3/include/std/deque23
-rw-r--r--libstdc++-v3/include/std/forward_list21
-rw-r--r--libstdc++-v3/include/std/list21
-rw-r--r--libstdc++-v3/include/std/map20
-rw-r--r--libstdc++-v3/include/std/set20
-rw-r--r--libstdc++-v3/include/std/string25
-rw-r--r--libstdc++-v3/include/std/unordered_map23
-rw-r--r--libstdc++-v3/include/std/unordered_set10
-rw-r--r--libstdc++-v3/include/std/vector23
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/erasure.cc53
-rw-r--r--libstdc++-v3/testsuite/23_containers/deque/erasure.cc52
-rw-r--r--libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc52
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/erasure.cc52
-rw-r--r--libstdc++-v3/testsuite/23_containers/map/erasure.cc61
-rw-r--r--libstdc++-v3/testsuite/23_containers/set/erasure.cc50
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_map/erasure.cc61
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc52
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/erasure.cc52
26 files changed, 720 insertions, 26 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 9ef71f1..dc989bc 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,33 @@
+2018-11-28 Edward Smith-Rowland <3dw4rd@verizon.net>
+
+ Implement uniform container erasure for C++20.
+ * include/Makefile.am: Move erase_if.h.
+ * include/Makefile.in: Move erase_if.h.
+ * include/experimental/bits/erase_if.h: Move ...
+ * include/bits/erase_if.h: ... here.
+ * include/experimental/map: Move erase_if.h.
+ * include/experimental/set: Move erase_if.h.
+ * include/experimental/unordered_map: Move erase_if.h.
+ * include/experimental/unordered_set: Move erase_if.h.
+ * include/std/deque (erase_if, erase): New functions.
+ * include/std/forward_list: Ditto.
+ * include/std/list: Ditto.
+ * include/std/map: Ditto.
+ * include/std/set: Ditto.
+ * include/std/string: Ditto.
+ * include/std/unordered_map: Ditto.
+ * include/std/unordered_set: Ditto.
+ * include/std/vector: Ditto.
+ * testsuite/21_strings/basic_string/erasure.cc: New test.
+ * testsuite/23_containers/deque/erasure.cc: New test.
+ * testsuite/23_containers/forward_list/erasure.cc: New test.
+ * testsuite/23_containers/list/erasure.cc: New test.
+ * testsuite/23_containers/map/erasure.cc: New test.
+ * testsuite/23_containers/set/erasure.cc: New test.
+ * testsuite/23_containers/unordered_map/erasure.cc: New test.
+ * testsuite/23_containers/unordered_set/erasure.cc: New test.
+ * testsuite/23_containers/vector/erasure.cc: New test.
+
2018-11-28 Jonathan Wakely <jwakely@redhat.com>
* doc/xml/manual/intro.xml: Document LWG 3096 change.
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index d45d937..09aa189 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -106,6 +106,7 @@ bits_headers = \
${bits_srcdir}/cpp_type_traits.h \
${bits_srcdir}/deque.tcc \
${bits_srcdir}/enable_special_members.h \
+ ${bits_srcdir}/erase_if.h \
${bits_srcdir}/forward_list.h \
${bits_srcdir}/forward_list.tcc \
${bits_srcdir}/fs_dir.h \
@@ -710,7 +711,6 @@ experimental_headers = \
experimental_bits_srcdir = ${glibcxx_srcdir}/include/experimental/bits
experimental_bits_builddir = ./experimental/bits
experimental_bits_headers = \
- ${experimental_bits_srcdir}/erase_if.h \
${experimental_bits_srcdir}/lfts_config.h \
${experimental_bits_srcdir}/net.h \
${experimental_bits_srcdir}/shared_ptr.h \
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 9a1df29..4d2642c 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -449,6 +449,7 @@ bits_headers = \
${bits_srcdir}/cpp_type_traits.h \
${bits_srcdir}/deque.tcc \
${bits_srcdir}/enable_special_members.h \
+ ${bits_srcdir}/erase_if.h \
${bits_srcdir}/forward_list.h \
${bits_srcdir}/forward_list.tcc \
${bits_srcdir}/fs_dir.h \
@@ -1052,7 +1053,6 @@ experimental_headers = \
experimental_bits_srcdir = ${glibcxx_srcdir}/include/experimental/bits
experimental_bits_builddir = ./experimental/bits
experimental_bits_headers = \
- ${experimental_bits_srcdir}/erase_if.h \
${experimental_bits_srcdir}/lfts_config.h \
${experimental_bits_srcdir}/net.h \
${experimental_bits_srcdir}/shared_ptr.h \
diff --git a/libstdc++-v3/include/experimental/bits/erase_if.h b/libstdc++-v3/include/bits/erase_if.h
index 62ffbc1..de4601f 100644
--- a/libstdc++-v3/include/experimental/bits/erase_if.h
+++ b/libstdc++-v3/include/bits/erase_if.h
@@ -1,4 +1,4 @@
-// <experimental/bits/erase_if.h> -*- C++ -*-
+// <bits/erase_if.h> -*- C++ -*-
// Copyright (C) 2015-2018 Free Software Foundation, Inc.
//
@@ -22,27 +22,22 @@
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
-/** @file experimental/bits/erase_if.h
+/** @file bits/erase_if.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly.
*/
-#ifndef _GLIBCXX_EXPERIMENTAL_ERASE_IF_H
-#define _GLIBCXX_EXPERIMENTAL_ERASE_IF_H 1
+#ifndef _GLIBCXX_ERASE_IF_H
+#define _GLIBCXX_ERASE_IF_H 1
#pragma GCC system_header
#if __cplusplus >= 201402L
-#include <experimental/bits/lfts_config.h>
namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
-namespace experimental
-{
-inline namespace fundamentals_v2
-{
namespace __detail
{
template<typename _Container, typename _Predicate>
@@ -59,12 +54,10 @@ inline namespace fundamentals_v2
}
}
} // namespace __detail
-} // inline namespace fundamentals_v2
-} // namespace experimental
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++14
-#endif // _GLIBCXX_EXPERIMENTAL_ERASE_IF_H
+#endif // _GLIBCXX_ERASE_IF_H
diff --git a/libstdc++-v3/include/experimental/map b/libstdc++-v3/include/experimental/map
index 5bd19e9..1e236e5 100644
--- a/libstdc++-v3/include/experimental/map
+++ b/libstdc++-v3/include/experimental/map
@@ -34,7 +34,7 @@
#if __cplusplus >= 201402L
#include <map>
-#include <experimental/bits/erase_if.h>
+#include <bits/erase_if.h>
#include <experimental/memory_resource>
namespace std _GLIBCXX_VISIBILITY(default)
@@ -49,13 +49,13 @@ inline namespace fundamentals_v2
typename _Predicate>
inline void
erase_if(map<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
- { __detail::__erase_nodes_if(__cont, __pred); }
+ { std::__detail::__erase_nodes_if(__cont, __pred); }
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc,
typename _Predicate>
inline void
erase_if(multimap<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
- { __detail::__erase_nodes_if(__cont, __pred); }
+ { std::__detail::__erase_nodes_if(__cont, __pred); }
namespace pmr {
template<typename _Key, typename _Tp, typename _Compare = less<_Key>>
diff --git a/libstdc++-v3/include/experimental/set b/libstdc++-v3/include/experimental/set
index 7c90ee1..4a3fae6 100644
--- a/libstdc++-v3/include/experimental/set
+++ b/libstdc++-v3/include/experimental/set
@@ -34,7 +34,7 @@
#if __cplusplus >= 201402L
#include <set>
-#include <experimental/bits/erase_if.h>
+#include <bits/erase_if.h>
#include <experimental/memory_resource>
namespace std _GLIBCXX_VISIBILITY(default)
@@ -49,13 +49,13 @@ inline namespace fundamentals_v2
typename _Predicate>
inline void
erase_if(set<_Key, _Compare, _Alloc>& __cont, _Predicate __pred)
- { __detail::__erase_nodes_if(__cont, __pred); }
+ { std::__detail::__erase_nodes_if(__cont, __pred); }
template<typename _Key, typename _Compare, typename _Alloc,
typename _Predicate>
inline void
erase_if(multiset<_Key, _Compare, _Alloc>& __cont, _Predicate __pred)
- { __detail::__erase_nodes_if(__cont, __pred); }
+ { std::__detail::__erase_nodes_if(__cont, __pred); }
namespace pmr {
template<typename _Key, typename _Compare = less<_Key>>
diff --git a/libstdc++-v3/include/experimental/unordered_map b/libstdc++-v3/include/experimental/unordered_map
index fdd3bf2..e1d2359 100644
--- a/libstdc++-v3/include/experimental/unordered_map
+++ b/libstdc++-v3/include/experimental/unordered_map
@@ -34,7 +34,7 @@
#if __cplusplus >= 201402L
#include <unordered_map>
-#include <experimental/bits/erase_if.h>
+#include <bits/erase_if.h>
#include <experimental/memory_resource>
namespace std _GLIBCXX_VISIBILITY(default)
@@ -50,14 +50,14 @@ inline namespace fundamentals_v2
inline void
erase_if(unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
_Predicate __pred)
- { __detail::__erase_nodes_if(__cont, __pred); }
+ { std::__detail::__erase_nodes_if(__cont, __pred); }
template<typename _Key, typename _Tp, typename _Hash, typename _CPred,
typename _Alloc, typename _Predicate>
inline void
erase_if(unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
_Predicate __pred)
- { __detail::__erase_nodes_if(__cont, __pred); }
+ { std::__detail::__erase_nodes_if(__cont, __pred); }
namespace pmr {
template<typename _Key, typename _Tp, typename _Hash = hash<_Key>,
diff --git a/libstdc++-v3/include/experimental/unordered_set b/libstdc++-v3/include/experimental/unordered_set
index 8e4fc1b..1b38369 100644
--- a/libstdc++-v3/include/experimental/unordered_set
+++ b/libstdc++-v3/include/experimental/unordered_set
@@ -34,7 +34,7 @@
#if __cplusplus >= 201402L
#include <unordered_set>
-#include <experimental/bits/erase_if.h>
+#include <bits/erase_if.h>
#include <experimental/memory_resource>
namespace std _GLIBCXX_VISIBILITY(default)
@@ -50,14 +50,14 @@ inline namespace fundamentals_v2
inline void
erase_if(unordered_set<_Key, _Hash, _CPred, _Alloc>& __cont,
_Predicate __pred)
- { __detail::__erase_nodes_if(__cont, __pred); }
+ { std::__detail::__erase_nodes_if(__cont, __pred); }
template<typename _Key, typename _Hash, typename _CPred, typename _Alloc,
typename _Predicate>
inline void
erase_if(unordered_multiset<_Key, _Hash, _CPred, _Alloc>& __cont,
_Predicate __pred)
- { __detail::__erase_nodes_if(__cont, __pred); }
+ { std::__detail::__erase_nodes_if(__cont, __pred); }
namespace pmr {
template<typename _Key, typename _Hash = hash<_Key>,
diff --git a/libstdc++-v3/include/std/deque b/libstdc++-v3/include/std/deque
index d2c75f1..c577e80 100644
--- a/libstdc++-v3/include/std/deque
+++ b/libstdc++-v3/include/std/deque
@@ -87,4 +87,27 @@ _GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
+#if __cplusplus > 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+ template<typename _Tp, typename _Alloc, typename _Predicate>
+ void
+ erase_if(deque<_Tp, _Alloc>& __cont, _Predicate __pred)
+ {
+ __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred),
+ __cont.end());
+ }
+
+ template<typename _Tp, typename _Alloc, typename _Up>
+ void
+ erase(deque<_Tp, _Alloc>& __cont, const _Up& __value)
+ {
+ __cont.erase(std::remove(__cont.begin(), __cont.end(), __value),
+ __cont.end());
+ }
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++20
+
#endif /* _GLIBCXX_DEQUE */
diff --git a/libstdc++-v3/include/std/forward_list b/libstdc++-v3/include/std/forward_list
index 00b4135..a2cc903 100644
--- a/libstdc++-v3/include/std/forward_list
+++ b/libstdc++-v3/include/std/forward_list
@@ -60,6 +60,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
+
+#if __cplusplus > 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+ template<typename _Tp, typename _Alloc, typename _Predicate>
+ inline void
+ erase_if(forward_list<_Tp, _Alloc>& __cont, _Predicate __pred)
+ { __cont.remove_if(__pred); }
+
+ template<typename _Tp, typename _Alloc, typename _Up>
+ inline void
+ erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value)
+ {
+ using __elem_type = typename forward_list<_Tp, _Alloc>::value_type;
+ erase_if(__cont, [&](__elem_type& __elem) { return __elem == __value; });
+ }
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++20
+
#endif // C++11
#endif // _GLIBCXX_FORWARD_LIST
diff --git a/libstdc++-v3/include/std/list b/libstdc++-v3/include/std/list
index 555371f..58ad461 100644
--- a/libstdc++-v3/include/std/list
+++ b/libstdc++-v3/include/std/list
@@ -84,4 +84,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
+
+#if __cplusplus > 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+ template<typename _Tp, typename _Alloc, typename _Predicate>
+ inline void
+ erase_if(list<_Tp, _Alloc>& __cont, _Predicate __pred)
+ { __cont.remove_if(__pred); }
+
+ template<typename _Tp, typename _Alloc, typename _Up>
+ inline void
+ erase(list<_Tp, _Alloc>& __cont, const _Up& __value)
+ {
+ using __elem_type = typename list<_Tp, _Alloc>::value_type;
+ erase_if(__cont, [&](__elem_type& __elem) { return __elem == __value; });
+ }
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++20
+
#endif /* _GLIBCXX_LIST */
diff --git a/libstdc++-v3/include/std/map b/libstdc++-v3/include/std/map
index 84f8cdb..26b2f0e 100644
--- a/libstdc++-v3/include/std/map
+++ b/libstdc++-v3/include/std/map
@@ -61,6 +61,7 @@
#include <bits/stl_map.h>
#include <bits/stl_multimap.h>
#include <bits/range_access.h>
+#include <bits/erase_if.h>
#ifdef _GLIBCXX_DEBUG
# include <debug/map>
@@ -90,4 +91,23 @@ _GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
+#if __cplusplus > 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc,
+ typename _Predicate>
+ inline void
+ erase_if(map<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
+ { __detail::__erase_nodes_if(__cont, __pred); }
+
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc,
+ typename _Predicate>
+ inline void
+ erase_if(multimap<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
+ { __detail::__erase_nodes_if(__cont, __pred); }
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++20
+
#endif /* _GLIBCXX_MAP */
diff --git a/libstdc++-v3/include/std/set b/libstdc++-v3/include/std/set
index dd41b2f..432af90 100644
--- a/libstdc++-v3/include/std/set
+++ b/libstdc++-v3/include/std/set
@@ -61,6 +61,7 @@
#include <bits/stl_set.h>
#include <bits/stl_multiset.h>
#include <bits/range_access.h>
+#include <bits/erase_if.h>
#ifdef _GLIBCXX_DEBUG
# include <debug/set>
@@ -86,4 +87,23 @@ _GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
+#if __cplusplus > 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+ template<typename _Key, typename _Compare, typename _Alloc,
+ typename _Predicate>
+ inline void
+ erase_if(set<_Key, _Compare, _Alloc>& __cont, _Predicate __pred)
+ { __detail::__erase_nodes_if(__cont, __pred); }
+
+ template<typename _Key, typename _Compare, typename _Alloc,
+ typename _Predicate>
+ inline void
+ erase_if(multiset<_Key, _Compare, _Alloc>& __cont, _Predicate __pred)
+ { __detail::__erase_nodes_if(__cont, __pred); }
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++20
+
#endif /* _GLIBCXX_SET */
diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string
index dd60df2..e1497bd 100644
--- a/libstdc++-v3/include/std/string
+++ b/libstdc++-v3/include/std/string
@@ -51,6 +51,7 @@
#include <bits/range_access.h>
#include <bits/basic_string.h>
#include <bits/basic_string.tcc>
+#include <algorithm> // For remove and remove_if
#if __cplusplus >= 201703L && _GLIBCXX_USE_CXX11_ABI
namespace std _GLIBCXX_VISIBILITY(default)
@@ -72,4 +73,28 @@ _GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
+#if __cplusplus > 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+ template<typename _CharT, typename _Traits, typename _Alloc,
+ typename _Predicate>
+ inline void
+ erase_if(basic_string<_CharT, _Traits, _Alloc>& __cont, _Predicate __pred)
+ {
+ __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred),
+ __cont.end());
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc, typename _Up>
+ inline void
+ erase(basic_string<_CharT, _Traits, _Alloc>& __cont, const _Up& __value)
+ {
+ __cont.erase(std::remove(__cont.begin(), __cont.end(), __value),
+ __cont.end());
+ }
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++20
+
#endif /* _GLIBCXX_STRING */
diff --git a/libstdc++-v3/include/std/unordered_map b/libstdc++-v3/include/std/unordered_map
index fc1b1e3..8cb8214 100644
--- a/libstdc++-v3/include/std/unordered_map
+++ b/libstdc++-v3/include/std/unordered_map
@@ -46,6 +46,7 @@
#include <bits/hashtable.h>
#include <bits/unordered_map.h>
#include <bits/range_access.h>
+#include <bits/erase_if.h>
#ifdef _GLIBCXX_DEBUG
# include <debug/unordered_map>
@@ -76,6 +77,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
+
+#if __cplusplus > 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+ template<typename _Key, typename _Tp, typename _Hash, typename _CPred,
+ typename _Alloc, typename _Predicate>
+ inline void
+ erase_if(unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
+ _Predicate __pred)
+ { __detail::__erase_nodes_if(__cont, __pred); }
+
+ template<typename _Key, typename _Tp, typename _Hash, typename _CPred,
+ typename _Alloc, typename _Predicate>
+ inline void
+ erase_if(unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
+ _Predicate __pred)
+ { __detail::__erase_nodes_if(__cont, __pred); }
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++20
+
#endif // C++11
#endif // _GLIBCXX_UNORDERED_MAP
diff --git a/libstdc++-v3/include/std/unordered_set b/libstdc++-v3/include/std/unordered_set
index 8c04669..3108275 100644
--- a/libstdc++-v3/include/std/unordered_set
+++ b/libstdc++-v3/include/std/unordered_set
@@ -46,6 +46,7 @@
#include <bits/hashtable.h>
#include <bits/unordered_set.h>
#include <bits/range_access.h>
+#include <bits/erase_if.h>
#ifdef _GLIBCXX_DEBUG
# include <debug/unordered_set>
@@ -76,6 +77,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
+
+#if __cplusplus > 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++20
+
#endif // C++11
#endif // _GLIBCXX_UNORDERED_SET
diff --git a/libstdc++-v3/include/std/vector b/libstdc++-v3/include/std/vector
index 2a421c6..5a1edaf 100644
--- a/libstdc++-v3/include/std/vector
+++ b/libstdc++-v3/include/std/vector
@@ -90,4 +90,27 @@ _GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++17
+#if __cplusplus > 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+ template<typename _Tp, typename _Alloc, typename _Predicate>
+ inline void
+ erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred)
+ {
+ __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred),
+ __cont.end());
+ }
+
+ template<typename _Tp, typename _Alloc, typename _Up>
+ inline void
+ erase(vector<_Tp, _Alloc>& __cont, const _Up& __value)
+ {
+ __cont.erase(std::remove(__cont.begin(), __cont.end(), __value),
+ __cont.end());
+ }
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++20
+
#endif /* _GLIBCXX_VECTOR */
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/erasure.cc b/libstdc++-v3/testsuite/21_strings/basic_string/erasure.cc
new file mode 100644
index 0000000..e9cca6f
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/erasure.cc
@@ -0,0 +1,53 @@
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ auto is_vowel = [](const char c)
+ {
+ return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
+ };
+
+ std::string str("cute fluffy kittens");
+ std::erase_if(str, is_vowel);
+ VERIFY( str == "ct flffy kttns" );
+}
+
+void
+test02()
+{
+ std::string str = "cute fluffy kittens";
+ std::erase(str, 'f');
+ VERIFY( str == "cute luy kittens" );
+ std::erase(str, 'z');
+ VERIFY( str == "cute luy kittens" );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/deque/erasure.cc b/libstdc++-v3/testsuite/23_containers/deque/erasure.cc
new file mode 100644
index 0000000..1fe6273
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/deque/erasure.cc
@@ -0,0 +1,52 @@
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <deque>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::deque<int> d{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::erase_if(d, is_odd);
+ std::deque<int> t{ 10, 12, 14, 18 };
+ VERIFY( d == t );
+}
+
+void
+test02()
+{
+ std::deque<int> d{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::erase(d, 14);
+ std::deque<int> t{ 10, 11, 12, 15, 17, 18, 19 };
+ VERIFY( d == t );
+ std::erase(d, 20);
+ VERIFY( d == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc b/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc
new file mode 100644
index 0000000..ac8a37d
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc
@@ -0,0 +1,52 @@
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <forward_list>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::forward_list<int> fl{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::erase_if(fl, is_odd);
+ std::forward_list<int> t{ 10, 12, 14, 18 };
+ VERIFY( fl == t );
+}
+
+void
+test02()
+{
+ std::forward_list<int> fl{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::erase(fl, 14);
+ std::forward_list<int> t{ 10, 11, 12, 15, 17, 18, 19 };
+ VERIFY( fl == t );
+ std::erase(fl, 20);
+ VERIFY( fl == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/erasure.cc b/libstdc++-v3/testsuite/23_containers/list/erasure.cc
new file mode 100644
index 0000000..c8d6f22
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/erasure.cc
@@ -0,0 +1,52 @@
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <list>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::list<int> l{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::erase_if(l, is_odd);
+ std::list<int> t{ 10, 12, 14, 18 };
+ VERIFY( l == t );
+}
+
+void
+test02()
+{
+ std::list<int> l{ 0, 11, 0, 0, 22, 33, 0, 0, 44, 0 };
+ std::erase(l, 0);
+ std::list<int> t{ 11, 22, 33, 44 };
+ VERIFY( l == t );
+ std::erase(l, 55);
+ VERIFY( l == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/map/erasure.cc b/libstdc++-v3/testsuite/23_containers/map/erasure.cc
new file mode 100644
index 0000000..d638715
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/map/erasure.cc
@@ -0,0 +1,61 @@
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <map>
+#include <testsuite_hooks.h>
+
+auto is_odd_pair = [](const std::pair<const int, std::string>& p)
+{
+ return p.first % 2 != 0;
+};
+
+void
+test01()
+{
+ std::map<int, std::string> m{ { 10, "A" }, { 11, "B" },
+ { 12, "C" }, { 14, "D" },
+ { 15, "E" }, { 17, "F" },
+ { 18, "G" }, { 19, "H" } };
+ std::erase_if(m, is_odd_pair);
+ std::map<int, std::string> t{ { 10, "A" }, { 12, "C" },
+ { 14, "D" }, { 18, "G" } };
+ VERIFY( m == t );
+}
+
+void
+test02()
+{
+ std::multimap<int, std::string> mm{ { 20, "S" }, { 21, "T" },
+ { 22, "U" }, { 22, "V" },
+ { 23, "W" }, { 23, "X" },
+ { 24, "Y" }, { 25, "Z" } };
+ std::erase_if(mm, is_odd_pair);
+ std::multimap<int, std::string> t{ { 20, "S" }, { 22, "U" },
+ { 22, "V" }, { 24, "Y" } };
+ VERIFY( mm == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/set/erasure.cc b/libstdc++-v3/testsuite/23_containers/set/erasure.cc
new file mode 100644
index 0000000..54b821b
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/set/erasure.cc
@@ -0,0 +1,50 @@
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <set>
+#include <testsuite_hooks.h>
+
+auto is_odd = [](const int i) { return i % 2 != 0; };
+
+void
+test01()
+{
+ std::set<int> s{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::erase_if(s, is_odd);
+ std::set<int> t{ 10, 12, 14, 18 };
+ VERIFY( s == t );
+}
+
+void
+test02()
+{
+ std::multiset<int> ms{ 20, 21, 22, 22, 23, 23, 24, 25 };
+ std::erase_if(ms, is_odd);
+ std::multiset<int> t{ 20, 22, 22, 24 };
+ VERIFY( ms == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/erasure.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/erasure.cc
new file mode 100644
index 0000000..0e17b4e2
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/erasure.cc
@@ -0,0 +1,61 @@
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <unordered_map>
+#include <testsuite_hooks.h>
+
+auto is_odd_pair = [](const std::pair<const int, std::string>& p)
+{
+ return p.first % 2 != 0;
+};
+
+void
+test01()
+{
+ std::unordered_map<int, std::string> um{ { 10, "A" }, { 11, "B" },
+ { 12, "C" }, { 14, "D" },
+ { 15, "E" }, { 17, "F" },
+ { 18, "G" }, { 19, "H" } };
+ std::erase_if(um, is_odd_pair);
+ std::unordered_map<int, std::string> t{ { 10, "A" }, { 12, "C" },
+ { 14, "D" }, { 18, "G" } };
+ VERIFY( um == t );
+}
+
+void
+test02()
+{
+ std::unordered_multimap<int, std::string> umm{ { 20, "S" }, { 21, "T" },
+ { 22, "U" }, { 22, "V" },
+ { 23, "W" }, { 23, "X" },
+ { 24, "Y" }, { 25, "Z" } };
+ std::erase_if(umm, is_odd_pair);
+ std::unordered_multimap<int, std::string> t{ { 20, "S" }, { 22, "U" },
+ { 22, "V" }, { 24, "Y" } };
+ VERIFY( umm == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc
new file mode 100644
index 0000000..5d32c32
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc
@@ -0,0 +1,52 @@
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <unordered_set>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::unordered_set<int> us{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::erase_if(us, is_odd);
+ std::unordered_set<int> t{ 10, 12, 14, 18 };
+ VERIFY( us == t );
+}
+
+void
+test02()
+{
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::unordered_multiset<int> ums{ 20, 21, 22, 22, 23, 23, 24, 25 };
+ std::erase_if(ums, is_odd);
+ std::unordered_multiset<int> t{ 20, 22, 22, 24 };
+ VERIFY( ums == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/erasure.cc b/libstdc++-v3/testsuite/23_containers/vector/erasure.cc
new file mode 100644
index 0000000..b050b54
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/erasure.cc
@@ -0,0 +1,52 @@
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <vector>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::vector<int> v{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::erase_if(v, is_odd);
+ std::vector<int> t{ 10, 12, 14, 18 };
+ VERIFY( v == t );
+}
+
+void
+test02()
+{
+ std::vector<int> v{ 0, 11, 0, 0, 22, 33, 0, 0, 44, 0 };
+ std::erase(v, 0);
+ std::vector<int> t{ 11, 22, 33, 44 };
+ VERIFY( v == t );
+ std::erase(v, 55);
+ VERIFY( v == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}