From a62b871d65a5c7ce3114ac095fa5490050f2037d Mon Sep 17 00:00:00 2001 From: Edward Smith-Rowland <3dw4rd@verizon.net> Date: Thu, 29 Nov 2018 13:43:55 +0000 Subject: [PATCH] Fix erasure goofs. 2018-11-29 Edward Smith-Rowland <3dw4rd@verizon.net> Fix erasure goofs. * include/experimental/deque: Make inline. * include/std/deque: Include bits/stl_algo.h. (erase, erase_if): Make inline. * include/std/string: Include bits/stl_algo.h. * include/std/unordered_set: Add erase, erase_if! * include/std/vector: Include bits/stl_algo.h. * testsuite/21_strings/basic_string/erasure.cc: Add { dg-options "-std=gnu++2a" }. * testsuite/23_containers/deque/erasure.cc: Ditto. * testsuite/23_containers/forward_list/erasure.cc: Ditto. * testsuite/23_containers/list/erasure.cc: Ditto. * testsuite/23_containers/map/erasure.cc: Ditto. * testsuite/23_containers/set/erasure.cc: Ditto. * testsuite/23_containers/unordered_map/erasure.cc: Ditto. * testsuite/23_containers/unordered_set/erasure.cc: Ditto. * testsuite/23_containers/vector/erasure.cc: Ditto. From-SVN: r266616 --- libstdc++-v3/ChangeLog | 20 +++++++++++++++++++ libstdc++-v3/include/experimental/deque | 4 ++-- libstdc++-v3/include/std/deque | 5 +++-- libstdc++-v3/include/std/string | 2 +- libstdc++-v3/include/std/unordered_set | 13 ++++++++++++ libstdc++-v3/include/std/vector | 1 + .../21_strings/basic_string/erasure.cc | 1 + .../testsuite/23_containers/deque/erasure.cc | 1 + .../23_containers/forward_list/erasure.cc | 1 + .../testsuite/23_containers/list/erasure.cc | 1 + .../testsuite/23_containers/map/erasure.cc | 1 + .../testsuite/23_containers/set/erasure.cc | 1 + .../23_containers/unordered_map/erasure.cc | 1 + .../23_containers/unordered_set/erasure.cc | 1 + .../testsuite/23_containers/vector/erasure.cc | 1 + 15 files changed, 49 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 553be512ec5..82a6e532f90 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,23 @@ +2018-11-29 Edward Smith-Rowland <3dw4rd@verizon.net> + + Fix erasure goofs. + * include/experimental/deque: Make inline. + * include/std/deque: Include bits/stl_algo.h. + (erase, erase_if): Make inline. + * include/std/string: Include bits/stl_algo.h. + * include/std/unordered_set: Add erase, erase_if! + * include/std/vector: Include bits/stl_algo.h. + * testsuite/21_strings/basic_string/erasure.cc: + Add { dg-options "-std=gnu++2a" }. + * testsuite/23_containers/deque/erasure.cc: Ditto. + * testsuite/23_containers/forward_list/erasure.cc: Ditto. + * testsuite/23_containers/list/erasure.cc: Ditto. + * testsuite/23_containers/map/erasure.cc: Ditto. + * testsuite/23_containers/set/erasure.cc: Ditto. + * testsuite/23_containers/unordered_map/erasure.cc: Ditto. + * testsuite/23_containers/unordered_set/erasure.cc: Ditto. + * testsuite/23_containers/vector/erasure.cc: Ditto. + 2018-11-29 Jonathan Wakely PR libstdc++/88119 diff --git a/libstdc++-v3/include/experimental/deque b/libstdc++-v3/include/experimental/deque index 88790b10936..e1ea13f4e97 100644 --- a/libstdc++-v3/include/experimental/deque +++ b/libstdc++-v3/include/experimental/deque @@ -46,7 +46,7 @@ namespace experimental inline namespace fundamentals_v2 { template - void + inline void erase_if(deque<_Tp, _Alloc>& __cont, _Predicate __pred) { __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred), @@ -54,7 +54,7 @@ inline namespace fundamentals_v2 } template - void + inline void erase(deque<_Tp, _Alloc>& __cont, const _Up& __value) { __cont.erase(std::remove(__cont.begin(), __cont.end(), __value), diff --git a/libstdc++-v3/include/std/deque b/libstdc++-v3/include/std/deque index c577e806513..764e1f17948 100644 --- a/libstdc++-v3/include/std/deque +++ b/libstdc++-v3/include/std/deque @@ -58,6 +58,7 @@ #pragma GCC system_header #include +#include // For remove and remove_if #include #include #include @@ -92,7 +93,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION template - void + inline void erase_if(deque<_Tp, _Alloc>& __cont, _Predicate __pred) { __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred), @@ -100,7 +101,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template - void + inline void erase(deque<_Tp, _Alloc>& __cont, const _Up& __value) { __cont.erase(std::remove(__cont.begin(), __cont.end(), __value), diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string index e1497bd2141..33cb5e6738c 100644 --- a/libstdc++-v3/include/std/string +++ b/libstdc++-v3/include/std/string @@ -48,10 +48,10 @@ #include // For less #include #include +#include // For remove and remove_if #include #include #include -#include // For remove and remove_if #if __cplusplus >= 201703L && _GLIBCXX_USE_CXX11_ABI namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/include/std/unordered_set b/libstdc++-v3/include/std/unordered_set index 310827528a6..a5e1e41815b 100644 --- a/libstdc++-v3/include/std/unordered_set +++ b/libstdc++-v3/include/std/unordered_set @@ -82,6 +82,19 @@ _GLIBCXX_END_NAMESPACE_VERSION namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + template + inline void + erase_if(unordered_set<_Key, _Hash, _CPred, _Alloc>& __cont, + _Predicate __pred) + { std::__detail::__erase_nodes_if(__cont, __pred); } + + template + inline void + erase_if(unordered_multiset<_Key, _Hash, _CPred, _Alloc>& __cont, + _Predicate __pred) + { std::__detail::__erase_nodes_if(__cont, __pred); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++20 diff --git a/libstdc++-v3/include/std/vector b/libstdc++-v3/include/std/vector index 5a1edaf9d74..720e0eb9cc3 100644 --- a/libstdc++-v3/include/std/vector +++ b/libstdc++-v3/include/std/vector @@ -58,6 +58,7 @@ #pragma GCC system_header #include +#include // For remove and remove_if #include #include #include diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/erasure.cc b/libstdc++-v3/testsuite/21_strings/basic_string/erasure.cc index e9cca6f4158..d8ac6a45297 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/erasure.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/erasure.cc @@ -1,3 +1,4 @@ +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } // Copyright (C) 2018 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/deque/erasure.cc b/libstdc++-v3/testsuite/23_containers/deque/erasure.cc index 1fe6273c984..1bb0b95d200 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/erasure.cc @@ -1,3 +1,4 @@ +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } // Copyright (C) 2018 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc b/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc index ac8a37d19d6..9d06ebe37e4 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc @@ -1,3 +1,4 @@ +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } // Copyright (C) 2018 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/list/erasure.cc b/libstdc++-v3/testsuite/23_containers/list/erasure.cc index c8d6f2212cc..ff4dbcf778b 100644 --- a/libstdc++-v3/testsuite/23_containers/list/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/list/erasure.cc @@ -1,3 +1,4 @@ +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } // Copyright (C) 2018 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/map/erasure.cc b/libstdc++-v3/testsuite/23_containers/map/erasure.cc index d638715e75a..58706a1be01 100644 --- a/libstdc++-v3/testsuite/23_containers/map/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/map/erasure.cc @@ -1,3 +1,4 @@ +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } // Copyright (C) 2018 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/set/erasure.cc b/libstdc++-v3/testsuite/23_containers/set/erasure.cc index 54b821b145d..1dccde8147e 100644 --- a/libstdc++-v3/testsuite/23_containers/set/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/set/erasure.cc @@ -1,3 +1,4 @@ +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } // Copyright (C) 2018 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/erasure.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/erasure.cc index 0e17b4e2be2..8a475482802 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/erasure.cc @@ -1,3 +1,4 @@ +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } // Copyright (C) 2018 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc index 5d32c3235c3..e5fcde00c01 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc @@ -1,3 +1,4 @@ +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } // Copyright (C) 2018 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/23_containers/vector/erasure.cc b/libstdc++-v3/testsuite/23_containers/vector/erasure.cc index b050b5422e8..57567d3338a 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/erasure.cc @@ -1,3 +1,4 @@ +// { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } // Copyright (C) 2018 Free Software Foundation, Inc. -- 2.30.2