From c0b12dad9334c280ea30445a94f673b145ef88cc Mon Sep 17 00:00:00 2001 From: Edward Smith-Rowland <3dw4rd@verizon.net> Date: Thu, 30 Apr 2015 14:43:19 +0000 Subject: [PATCH] Add fundamentals TR container erasure. 2015-04-30 Edward Smith-Rowland <3dw4rd@verizon.net> Add fundamentals TR container erasure. * include/Makefile.am: Add new headers. * include/Makefile.in: Add new headers. * include/experimental/array: New. * include/experimental/deque: New. * include/experimental/erase_if.tcc: New. * include/experimental/forward_list: New. * include/experimental/list: New. * include/experimental/map: New. * include/experimental/set: New. * include/experimental/string: New. * include/experimental/unordered_map: New. * include/experimental/unordered_set: New. * include/experimental/vector: New. * testsuite/experimental/deque/erasure.cc: New. * testsuite/experimental/forward_list/erasure.cc: New. * testsuite/experimental/list/erasure.cc: New. * testsuite/experimental/map/erasure.cc: New. * testsuite/experimental/set/erasure.cc: New. * testsuite/experimental/string/erasure.cc: New. * testsuite/experimental/unordered_map/erasure.cc: New. * testsuite/experimental/unordered_set/erasure.cc: New. * testsuite/experimental/vector/erasure.cc: New. From-SVN: r222630 --- libstdc++-v3/ChangeLog | 26 +++++++ libstdc++-v3/include/Makefile.am | 14 +++- libstdc++-v3/include/Makefile.in | 14 +++- libstdc++-v3/include/experimental/deque | 72 ++++++++++++++++++ libstdc++-v3/include/experimental/erase_if.h | 70 ++++++++++++++++++ .../include/experimental/forward_list | 67 +++++++++++++++++ libstdc++-v3/include/experimental/list | 68 +++++++++++++++++ libstdc++-v3/include/experimental/map | 68 +++++++++++++++++ libstdc++-v3/include/experimental/set | 68 +++++++++++++++++ libstdc++-v3/include/experimental/string | 73 +++++++++++++++++++ .../include/experimental/unordered_map | 70 ++++++++++++++++++ .../include/experimental/unordered_set | 70 ++++++++++++++++++ libstdc++-v3/include/experimental/vector | 72 ++++++++++++++++++ .../testsuite/experimental/deque/erasure.cc | 57 +++++++++++++++ .../experimental/forward_list/erasure.cc | 57 +++++++++++++++ .../testsuite/experimental/list/erasure.cc | 57 +++++++++++++++ .../testsuite/experimental/map/erasure.cc | 66 +++++++++++++++++ .../testsuite/experimental/set/erasure.cc | 55 ++++++++++++++ .../testsuite/experimental/string/erasure.cc | 58 +++++++++++++++ .../experimental/unordered_map/erasure.cc | 66 +++++++++++++++++ .../experimental/unordered_set/erasure.cc | 57 +++++++++++++++ .../testsuite/experimental/vector/erasure.cc | 57 +++++++++++++++ 22 files changed, 1278 insertions(+), 4 deletions(-) create mode 100644 libstdc++-v3/include/experimental/deque create mode 100644 libstdc++-v3/include/experimental/erase_if.h create mode 100644 libstdc++-v3/include/experimental/forward_list create mode 100644 libstdc++-v3/include/experimental/list create mode 100644 libstdc++-v3/include/experimental/map create mode 100644 libstdc++-v3/include/experimental/set create mode 100644 libstdc++-v3/include/experimental/string create mode 100644 libstdc++-v3/include/experimental/unordered_map create mode 100644 libstdc++-v3/include/experimental/unordered_set create mode 100644 libstdc++-v3/include/experimental/vector create mode 100644 libstdc++-v3/testsuite/experimental/deque/erasure.cc create mode 100644 libstdc++-v3/testsuite/experimental/forward_list/erasure.cc create mode 100644 libstdc++-v3/testsuite/experimental/list/erasure.cc create mode 100644 libstdc++-v3/testsuite/experimental/map/erasure.cc create mode 100644 libstdc++-v3/testsuite/experimental/set/erasure.cc create mode 100644 libstdc++-v3/testsuite/experimental/string/erasure.cc create mode 100644 libstdc++-v3/testsuite/experimental/unordered_map/erasure.cc create mode 100644 libstdc++-v3/testsuite/experimental/unordered_set/erasure.cc create mode 100644 libstdc++-v3/testsuite/experimental/vector/erasure.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 53661dfa9bd..28f1b8b1474 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,29 @@ +2015-04-30 Edward Smith-Rowland <3dw4rd@verizon.net> + + Add fundamentals TR container erasure. + * include/Makefile.am: Add new headers. + * include/Makefile.in: Add new headers. + * include/experimental/array: New. + * include/experimental/deque: New. + * include/experimental/erase_if.tcc: New. + * include/experimental/forward_list: New. + * include/experimental/list: New. + * include/experimental/map: New. + * include/experimental/set: New. + * include/experimental/string: New. + * include/experimental/unordered_map: New. + * include/experimental/unordered_set: New. + * include/experimental/vector: New. + * testsuite/experimental/deque/erasure.cc: New. + * testsuite/experimental/forward_list/erasure.cc: New. + * testsuite/experimental/list/erasure.cc: New. + * testsuite/experimental/map/erasure.cc: New. + * testsuite/experimental/set/erasure.cc: New. + * testsuite/experimental/string/erasure.cc: New. + * testsuite/experimental/unordered_map/erasure.cc: New. + * testsuite/experimental/unordered_set/erasure.cc: New. + * testsuite/experimental/vector/erasure.cc: New. + 2015-04-30 François Dumont * include/bits/cpp_type_traits.h diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 26771322495..d582dff8708 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -646,14 +646,24 @@ experimental_headers = \ ${experimental_srcdir}/algorithm \ ${experimental_srcdir}/any \ ${experimental_srcdir}/chrono \ + ${experimental_srcdir}/deque \ + ${experimental_srcdir}/erase_if.h \ + ${experimental_srcdir}/forward_list \ ${experimental_srcdir}/functional \ + ${experimental_srcdir}/list \ + ${experimental_srcdir}/map \ ${experimental_srcdir}/optional \ ${experimental_srcdir}/ratio \ + ${experimental_srcdir}/set \ + ${experimental_srcdir}/string \ ${experimental_srcdir}/string_view \ - ${experimental_srcdir}/system_error \ ${experimental_srcdir}/string_view.tcc \ + ${experimental_srcdir}/system_error \ ${experimental_srcdir}/tuple \ - ${experimental_srcdir}/type_traits + ${experimental_srcdir}/type_traits \ + ${experimental_srcdir}/unordered_map \ + ${experimental_srcdir}/unordered_set \ + ${experimental_srcdir}/vector # This is the common subset of C++ files that all three "C" header models use. c_base_srcdir = $(C_INCLUDE_DIR) diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 9c423cb4341..f9328e167eb 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -913,14 +913,24 @@ experimental_headers = \ ${experimental_srcdir}/algorithm \ ${experimental_srcdir}/any \ ${experimental_srcdir}/chrono \ + ${experimental_srcdir}/deque \ + ${experimental_srcdir}/erase_if.h \ + ${experimental_srcdir}/forward_list \ ${experimental_srcdir}/functional \ + ${experimental_srcdir}/list \ + ${experimental_srcdir}/map \ ${experimental_srcdir}/optional \ ${experimental_srcdir}/ratio \ + ${experimental_srcdir}/set \ + ${experimental_srcdir}/string \ ${experimental_srcdir}/string_view \ - ${experimental_srcdir}/system_error \ ${experimental_srcdir}/string_view.tcc \ + ${experimental_srcdir}/system_error \ ${experimental_srcdir}/tuple \ - ${experimental_srcdir}/type_traits + ${experimental_srcdir}/type_traits \ + ${experimental_srcdir}/unordered_map \ + ${experimental_srcdir}/unordered_set \ + ${experimental_srcdir}/vector # This is the common subset of C++ files that all three "C" header models use. diff --git a/libstdc++-v3/include/experimental/deque b/libstdc++-v3/include/experimental/deque new file mode 100644 index 00000000000..8d3d8951e3a --- /dev/null +++ b/libstdc++-v3/include/experimental/deque @@ -0,0 +1,72 @@ +// -*- C++ -*- + +// Copyright (C) 2015 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/deque + * This is a TS C++ Library header. + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_DEQUE +#define _GLIBCXX_EXPERIMENTAL_DEQUE 1 + +#pragma GCC system_header + +#if __cplusplus <= 201103L +# include +#else + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace experimental +{ +inline namespace fundamentals_v2 +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + erase_if(deque<_Tp, _Alloc>& __cont, _Predicate __pred) + { + __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred), + __cont.end()); + } + + template + 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 fundamentals_v2 +} // namespace experimental +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_DEQUE diff --git a/libstdc++-v3/include/experimental/erase_if.h b/libstdc++-v3/include/experimental/erase_if.h new file mode 100644 index 00000000000..35b5b377889 --- /dev/null +++ b/libstdc++-v3/include/experimental/erase_if.h @@ -0,0 +1,70 @@ +// -*- C++ -*- + +// Copyright (C) 2015 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/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 + +#pragma GCC system_header + +#if __cplusplus <= 201103L +# include +#else + +namespace std +{ +namespace experimental +{ +inline namespace fundamentals_v2 +{ + + namespace __detail + { + template + void + __erase_nodes_if(_Container& __cont, _Predicate __pred) + { + for (auto __iter = __cont.begin(), __last = __cont.end(); + __iter != __last;) + { + if (__pred(*__iter)) + __iter = __cont.erase(__iter); + else + ++__iter; + } + } + } + + +} // inline namespace fundamentals_v2 +} // namespace experimental +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_ERASE_IF_H diff --git a/libstdc++-v3/include/experimental/forward_list b/libstdc++-v3/include/experimental/forward_list new file mode 100644 index 00000000000..482ac126c8b --- /dev/null +++ b/libstdc++-v3/include/experimental/forward_list @@ -0,0 +1,67 @@ +// -*- C++ -*- + +// Copyright (C) 2015 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/forward_list + * This is a TS C++ Library header. + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_FORWARD_LIST +#define _GLIBCXX_EXPERIMENTAL_FORWARD_LIST 1 + +#pragma GCC system_header + +#if __cplusplus <= 201103L +# include +#else + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace experimental +{ +inline namespace fundamentals_v2 +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + erase_if(forward_list<_Tp, _Alloc>& __cont, _Predicate __pred) + { __cont.remove_if(__pred); } + + template + 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 fundamentals_v2 +} // namespace experimental +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_FORWARD_LIST diff --git a/libstdc++-v3/include/experimental/list b/libstdc++-v3/include/experimental/list new file mode 100644 index 00000000000..9bdf8d5ed16 --- /dev/null +++ b/libstdc++-v3/include/experimental/list @@ -0,0 +1,68 @@ +// -*- C++ -*- + +// Copyright (C) 2015 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/list + * This is a TS C++ Library header. + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_LIST +#define _GLIBCXX_EXPERIMENTAL_LIST 1 + +#pragma GCC system_header + +#if __cplusplus <= 201103L +# include +#else + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace experimental +{ +inline namespace fundamentals_v2 +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + erase_if(list<_Tp, _Alloc>& __cont, _Predicate __pred) + { __cont.remove_if(__pred); } + + template + 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 fundamentals_v2 +} // namespace experimental +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_LIST diff --git a/libstdc++-v3/include/experimental/map b/libstdc++-v3/include/experimental/map new file mode 100644 index 00000000000..c2b5a09e873 --- /dev/null +++ b/libstdc++-v3/include/experimental/map @@ -0,0 +1,68 @@ +// -*- C++ -*- + +// Copyright (C) 2015 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/map + * This is a TS C++ Library header. + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_MAP +#define _GLIBCXX_EXPERIMENTAL_MAP 1 + +#pragma GCC system_header + +#if __cplusplus <= 201103L +# include +#else + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace experimental +{ +inline namespace fundamentals_v2 +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + erase_if(map<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred) + { __detail::__erase_nodes_if(__cont, __pred); } + + template + void + erase_if(multimap<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred) + { __detail::__erase_nodes_if(__cont, __pred); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace fundamentals_v2 +} // namespace experimental +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_MAP diff --git a/libstdc++-v3/include/experimental/set b/libstdc++-v3/include/experimental/set new file mode 100644 index 00000000000..7b87848fca9 --- /dev/null +++ b/libstdc++-v3/include/experimental/set @@ -0,0 +1,68 @@ +// -*- C++ -*- + +// Copyright (C) 2015 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/set + * This is a TS C++ Library header. + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_SET +#define _GLIBCXX_EXPERIMENTAL_SET 1 + +#pragma GCC system_header + +#if __cplusplus <= 201103L +# include +#else + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace experimental +{ +inline namespace fundamentals_v2 +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + erase_if(set<_Key, _Compare, _Alloc>& __cont, _Predicate __pred) + { __detail::__erase_nodes_if(__cont, __pred); } + + template + void + erase_if(multiset<_Key, _Compare, _Alloc>& __cont, _Predicate __pred) + { __detail::__erase_nodes_if(__cont, __pred); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace fundamentals_v2 +} // namespace experimental +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_SET diff --git a/libstdc++-v3/include/experimental/string b/libstdc++-v3/include/experimental/string new file mode 100644 index 00000000000..70212fbd8b0 --- /dev/null +++ b/libstdc++-v3/include/experimental/string @@ -0,0 +1,73 @@ +// -*- C++ -*- + +// Copyright (C) 2015 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/string + * This is a TS C++ Library header. + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_STRING +#define _GLIBCXX_EXPERIMENTAL_STRING 1 + +#pragma GCC system_header + +#if __cplusplus <= 201103L +# include +#else + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace experimental +{ +inline namespace fundamentals_v2 +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + erase_if(basic_string<_CharT, _Traits, _Alloc>& __cont, _Predicate __pred) + { + __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred), + __cont.end()); + } + + template + 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 fundamentals_v2 +} // namespace experimental +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_STRING diff --git a/libstdc++-v3/include/experimental/unordered_map b/libstdc++-v3/include/experimental/unordered_map new file mode 100644 index 00000000000..438f886d6c8 --- /dev/null +++ b/libstdc++-v3/include/experimental/unordered_map @@ -0,0 +1,70 @@ +// -*- C++ -*- + +// Copyright (C) 2015 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/unordered_map + * This is a TS C++ Library header. + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_UNORDERED_MAP +#define _GLIBCXX_EXPERIMENTAL_UNORDERED_MAP 1 + +#pragma GCC system_header + +#if __cplusplus <= 201103L +# include +#else + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace experimental +{ +inline namespace fundamentals_v2 +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + erase_if(unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont, + _Predicate __pred) + { __detail::__erase_nodes_if(__cont, __pred); } + + template + void + erase_if(unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont, + _Predicate __pred) + { __detail::__erase_nodes_if(__cont, __pred); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace fundamentals_v2 +} // namespace experimental +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_UNORDERED_MAP diff --git a/libstdc++-v3/include/experimental/unordered_set b/libstdc++-v3/include/experimental/unordered_set new file mode 100644 index 00000000000..44610475e55 --- /dev/null +++ b/libstdc++-v3/include/experimental/unordered_set @@ -0,0 +1,70 @@ +// -*- C++ -*- + +// Copyright (C) 2015 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/unordered_set + * This is a TS C++ Library header. + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_UNORDERED_SET +#define _GLIBCXX_EXPERIMENTAL_UNORDERED_SET 1 + +#pragma GCC system_header + +#if __cplusplus <= 201103L +# include +#else + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace experimental +{ +inline namespace fundamentals_v2 +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + erase_if(unordered_set<_Key, _Hash, _CPred, _Alloc>& __cont, + _Predicate __pred) + { __detail::__erase_nodes_if(__cont, __pred); } + + template + void + erase_if(unordered_multiset<_Key, _Hash, _CPred, _Alloc>& __cont, + _Predicate __pred) + { __detail::__erase_nodes_if(__cont, __pred); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace fundamentals_v2 +} // namespace experimental +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_UNORDERED_SET diff --git a/libstdc++-v3/include/experimental/vector b/libstdc++-v3/include/experimental/vector new file mode 100644 index 00000000000..2d4c1f75cdb --- /dev/null +++ b/libstdc++-v3/include/experimental/vector @@ -0,0 +1,72 @@ +// -*- C++ -*- + +// Copyright (C) 2015 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/vector + * This is a TS C++ Library header. + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_VECTOR +#define _GLIBCXX_EXPERIMENTAL_VECTOR 1 + +#pragma GCC system_header + +#if __cplusplus <= 201103L +# include +#else + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace experimental +{ +inline namespace fundamentals_v2 +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred) + { + __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred), + __cont.end()); + } + + template + 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 fundamentals_v2 +} // namespace experimental +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_VECTOR diff --git a/libstdc++-v3/testsuite/experimental/deque/erasure.cc b/libstdc++-v3/testsuite/experimental/deque/erasure.cc new file mode 100644 index 00000000000..9cec2bc5403 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/deque/erasure.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++14" } +// { dg-do run } + +// Copyright (C) 2015 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 moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void +test01() +{ + bool test [[gnu::unused]] = true; + + auto is_odd = [](const int i) { return i % 2 != 0; }; + + std::deque d{ 10, 11, 12, 14, 15, 17, 18, 19 }; + std::experimental::erase_if(d, is_odd); + std::deque t{ 10, 12, 14, 18 }; + VERIFY( d == t ); +} + +void +test02() +{ + bool test [[gnu::unused]] = true; + + std::deque d{ 10, 11, 12, 14, 15, 17, 18, 19 }; + std::experimental::erase(d, 14); + std::deque t{ 10, 11, 12, 15, 17, 18, 19 }; + VERIFY( d == t ); + std::experimental::erase(d, 20); + VERIFY( d == t ); +} + +int +main() +{ + test01(); + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/experimental/forward_list/erasure.cc b/libstdc++-v3/testsuite/experimental/forward_list/erasure.cc new file mode 100644 index 00000000000..f5e1184598d --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/forward_list/erasure.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++14" } +// { dg-do run } + +// Copyright (C) 2015 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 moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void +test01() +{ + bool test [[gnu::unused]] = true; + + auto is_odd = [](const int i) { return i % 2 != 0; }; + + std::forward_list fl{ 10, 11, 12, 14, 15, 17, 18, 19 }; + std::experimental::erase_if(fl, is_odd); + std::forward_list t{ 10, 12, 14, 18 }; + VERIFY( fl == t ); +} + +void +test02() +{ + bool test [[gnu::unused]] = true; + + std::forward_list fl{ 10, 11, 12, 14, 15, 17, 18, 19 }; + std::experimental::erase(fl, 14); + std::forward_list t{ 10, 11, 12, 15, 17, 18, 19 }; + VERIFY( fl == t ); + std::experimental::erase(fl, 20); + VERIFY( fl == t ); +} + +int +main() +{ + test01(); + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/experimental/list/erasure.cc b/libstdc++-v3/testsuite/experimental/list/erasure.cc new file mode 100644 index 00000000000..5aa6c87e3e1 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/list/erasure.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++14" } +// { dg-do run } + +// Copyright (C) 2015 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 moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void +test01() +{ + bool test [[gnu::unused]] = true; + + auto is_odd = [](const int i) { return i % 2 != 0; }; + + std::list l{ 10, 11, 12, 14, 15, 17, 18, 19 }; + std::experimental::erase_if(l, is_odd); + std::list t{ 10, 12, 14, 18 }; + VERIFY( l == t ); +} + +void +test02() +{ + bool test [[gnu::unused]] = true; + + std::list l{ 0, 11, 0, 0, 22, 33, 0, 0, 44, 0 }; + std::experimental::erase(l, 0); + std::list t{ 11, 22, 33, 44 }; + VERIFY( l == t ); + std::experimental::erase(l, 55); + VERIFY( l == t ); +} + +int +main() +{ + test01(); + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/experimental/map/erasure.cc b/libstdc++-v3/testsuite/experimental/map/erasure.cc new file mode 100644 index 00000000000..83547b90b80 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/map/erasure.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++14" } +// { dg-do run } + +// Copyright (C) 2015 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 moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +auto is_odd_pair = [](const std::pair& p) +{ + return p.first % 2 != 0; +}; + +void +test01() +{ + bool test [[gnu::unused]] = true; + + std::map m{ { 10, "A" }, { 11, "B" }, + { 12, "C" }, { 14, "D" }, + { 15, "E" }, { 17, "F" }, + { 18, "G" }, { 19, "H" } }; + std::experimental::erase_if(m, is_odd_pair); + std::map t{ { 10, "A" }, { 12, "C" }, + { 14, "D" }, { 18, "G" } }; + VERIFY( m == t ); +} + +void +test02() +{ + bool test [[gnu::unused]] = true; + + std::multimap mm{ { 20, "S" }, { 21, "T" }, + { 22, "U" }, { 22, "V" }, + { 23, "W" }, { 23, "X" }, + { 24, "Y" }, { 25, "Z" } }; + std::experimental::erase_if(mm, is_odd_pair); + std::multimap t{ { 20, "S" }, { 22, "U" }, + { 22, "V" }, { 24, "Y" } }; + VERIFY( mm == t ); +} + +int +main() +{ + test01(); + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/experimental/set/erasure.cc b/libstdc++-v3/testsuite/experimental/set/erasure.cc new file mode 100644 index 00000000000..a7f9a577cab --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/set/erasure.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++14" } +// { dg-do run } + +// Copyright (C) 2015 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 moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +auto is_odd = [](const int i) { return i % 2 != 0; }; + +void +test01() +{ + bool test [[gnu::unused]] = true; + + std::set s{ 10, 11, 12, 14, 15, 17, 18, 19 }; + std::experimental::erase_if(s, is_odd); + std::set t{ 10, 12, 14, 18 }; + VERIFY( s == t ); +} + +void +test02() +{ + bool test [[gnu::unused]] = true; + + std::multiset ms{ 20, 21, 22, 22, 23, 23, 24, 25 }; + std::experimental::erase_if(ms, is_odd); + std::multiset t{ 20, 22, 22, 24 }; + VERIFY( ms == t ); +} + +int +main() +{ + test01(); + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/experimental/string/erasure.cc b/libstdc++-v3/testsuite/experimental/string/erasure.cc new file mode 100644 index 00000000000..aaa506d5398 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/string/erasure.cc @@ -0,0 +1,58 @@ +// { dg-options "-std=gnu++14" } +// { dg-do run } + +// Copyright (C) 2015 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 moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void +test01() +{ + bool test [[gnu::unused]] = true; + + auto is_vowel = [](const char c) + { + return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'; + }; + + std::string str("cute fluffy kittens"); + std::experimental::erase_if(str, is_vowel); + VERIFY( str == "ct flffy kttns" ); +} + +void +test02() +{ + bool test [[gnu::unused]] = true; + + std::string str = "cute fluffy kittens"; + std::experimental::erase(str, 'f'); + VERIFY( str == "cute luy kittens" ); + std::experimental::erase(str, 'z'); + VERIFY( str == "cute luy kittens" ); +} + +int +main() +{ + test01(); + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/experimental/unordered_map/erasure.cc b/libstdc++-v3/testsuite/experimental/unordered_map/erasure.cc new file mode 100644 index 00000000000..bb2e4350c73 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/unordered_map/erasure.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++14" } +// { dg-do run } + +// Copyright (C) 2015 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 moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +auto is_odd_pair = [](const std::pair& p) +{ + return p.first % 2 != 0; +}; + +void +test01() +{ + bool test [[gnu::unused]] = true; + + std::unordered_map um{ { 10, "A" }, { 11, "B" }, + { 12, "C" }, { 14, "D" }, + { 15, "E" }, { 17, "F" }, + { 18, "G" }, { 19, "H" } }; + std::experimental::erase_if(um, is_odd_pair); + std::unordered_map t{ { 10, "A" }, { 12, "C" }, + { 14, "D" }, { 18, "G" } }; + VERIFY( um == t ); +} + +void +test02() +{ + bool test [[gnu::unused]] = true; + + std::unordered_multimap umm{ { 20, "S" }, { 21, "T" }, + { 22, "U" }, { 22, "V" }, + { 23, "W" }, { 23, "X" }, + { 24, "Y" }, { 25, "Z" } }; + std::experimental::erase_if(umm, is_odd_pair); + std::unordered_multimap t{ { 20, "S" }, { 22, "U" }, + { 22, "V" }, { 24, "Y" } }; + VERIFY( umm == t ); +} + +int +main() +{ + test01(); + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/experimental/unordered_set/erasure.cc b/libstdc++-v3/testsuite/experimental/unordered_set/erasure.cc new file mode 100644 index 00000000000..f296e35057e --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/unordered_set/erasure.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++14" } +// { dg-do run } + +// Copyright (C) 2015 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 moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void +test01() +{ + bool test [[gnu::unused]] = true; + + auto is_odd = [](const int i) { return i % 2 != 0; }; + + std::unordered_set us{ 10, 11, 12, 14, 15, 17, 18, 19 }; + std::experimental::erase_if(us, is_odd); + std::unordered_set t{ 10, 12, 14, 18 }; + VERIFY( us == t ); +} + +void +test02() +{ + bool test [[gnu::unused]] = true; + + auto is_odd = [](const int i) { return i % 2 != 0; }; + + std::unordered_multiset ums{ 20, 21, 22, 22, 23, 23, 24, 25 }; + std::experimental::erase_if(ums, is_odd); + std::unordered_multiset t{ 20, 22, 22, 24 }; + VERIFY( ums == t ); +} + +int +main() +{ + test01(); + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/experimental/vector/erasure.cc b/libstdc++-v3/testsuite/experimental/vector/erasure.cc new file mode 100644 index 00000000000..98ba2860ece --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/vector/erasure.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++14" } +// { dg-do run } + +// Copyright (C) 2015 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 moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void +test01() +{ + bool test [[gnu::unused]] = true; + + auto is_odd = [](const int i) { return i % 2 != 0; }; + + std::vector v{ 10, 11, 12, 14, 15, 17, 18, 19 }; + std::experimental::erase_if(v, is_odd); + std::vector t{ 10, 12, 14, 18 }; + VERIFY( v == t ); +} + +void +test02() +{ + bool test [[gnu::unused]] = true; + + std::vector v{ 0, 11, 0, 0, 22, 33, 0, 0, 44, 0 }; + std::experimental::erase(v, 0); + std::vector t{ 11, 22, 33, 44 }; + VERIFY( v == t ); + std::experimental::erase(v, 55); + VERIFY( v == t ); +} + +int +main() +{ + test01(); + test02(); + + return 0; +} -- 2.30.2