* [PATCH] [libstdc++] Add uniform container erasure.
@ 2015-04-30 11:40 Ed Smith-Rowland
2015-04-30 12:47 ` Jonathan Wakely
0 siblings, 1 reply; 6+ messages in thread
From: Ed Smith-Rowland @ 2015-04-30 11:40 UTC (permalink / raw)
To: gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 158 bytes --]
This has been in me tree for a good while.
It is fairly simple and adds C++ experimental container erasure.
Builds and tests cleanly on x86_64-linux.
OK?
[-- Attachment #2: patch_erasure --]
[-- Type: text/plain, Size: 48782 bytes --]
Index: include/Makefile.am
===================================================================
--- include/Makefile.am (revision 222573)
+++ include/Makefile.am (working copy)
@@ -645,15 +645,26 @@
experimental_headers = \
${experimental_srcdir}/algorithm \
${experimental_srcdir}/any \
+ ${experimental_srcdir}/array \
${experimental_srcdir}/chrono \
+ ${experimental_srcdir}/deque \
+ ${experimental_srcdir}/erase_if.tcc \
+ ${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}/string_view.tcc \
${experimental_srcdir}/system_error \
- ${experimental_srcdir}/string_view.tcc \
${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)
Index: include/Makefile.in
===================================================================
--- include/Makefile.in (revision 222573)
+++ include/Makefile.in (working copy)
@@ -912,15 +912,26 @@
experimental_headers = \
${experimental_srcdir}/algorithm \
${experimental_srcdir}/any \
+ ${experimental_srcdir}/array \
${experimental_srcdir}/chrono \
+ ${experimental_srcdir}/deque \
+ ${experimental_srcdir}/erase_if.tcc \
+ ${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}/string_view.tcc \
${experimental_srcdir}/system_error \
- ${experimental_srcdir}/string_view.tcc \
${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.
Index: include/experimental/array
===================================================================
--- include/experimental/array (revision 0)
+++ include/experimental/array (working copy)
@@ -0,0 +1,180 @@
+// https://gist.github.com/lichray/6034753
+// <experimental/array> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @file experimental/functional
+ * This is a TS C++ Library header.
+ */
+
+#ifndef _GLIBCXX_EXPERIMENTAL_ARRAY
+#define _GLIBCXX_EXPERIMENTAL_ARRAY 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+#include <array>
+#include <functional>
+#include <type_traits>
+
+namespace std
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+
+// Made this up...
+#define __cpp_lib_experimental_make_array 201411
+
+namespace __detail
+{
+
+ template<bool, typename _Tp, typename... _Up>
+ struct __lazy_conditional;
+
+ template<typename _Tp>
+ struct __lazy_conditional<true, _Tp>
+ {
+ using type = typename _Tp::type;
+ };
+
+ template<typename _Tp, typename _Up>
+ struct __lazy_conditional<true, _Tp, _Up>
+ {
+ using type = typename _Tp::type;
+ };
+
+ template<typename _Tp, typename _Up>
+ struct __lazy_conditional<false, _Tp, _Up>
+ {
+ using type = typename _Up::type;
+ };
+
+ template<typename _Vp, typename _Tp, typename... _Up>
+ using __if = __lazy_conditional<_Vp::value, _Tp, _Up...>;
+
+ template<typename _Vp, typename _Tp, typename... _Up>
+ using __if_t = typename __if<_Vp, _Tp, _Up...>::type;
+
+
+ template<template<typename> typename _F, typename... _Tp>
+ struct __no_type
+ : std::true_type
+ { };
+
+ template<template<typename> typename _F, typename _Tp, typename... _Up>
+ struct __no_type<_F, _Tp, _Up...>
+ : std::integral_constant<bool, ! _F<_Tp>::value
+ && __no_type<_F, _Up...>::value>
+ { };
+
+
+ template<template<typename> typename _F,
+ template<typename> typename _G>
+ struct __compose
+ {
+ template<typename _Tp>
+ using __call = _F<typename _G<_Tp>::type>;
+ };
+
+
+ template<typename _Tp>
+ struct __is_reference_wrapper_helper
+ : std::false_type
+ { };
+
+ template<typename _Tp>
+ struct __is_reference_wrapper_helper<std::reference_wrapper<_Tp>>
+ : std::true_type
+ { };
+
+ template<typename _Tp>
+ using __is_reference_wrapper =
+ __compose<__is_reference_wrapper_helper, std::remove_cv>::__call<_Tp>;
+
+
+ template<typename _Tp, size_t _Num, size_t... _Idx>
+ constexpr auto
+ __to_array_helper(_Tp (&__arr)[_Num], std::index_sequence<_Idx...>)
+ -> std::array<remove_cv_t<_Tp>, _Num>
+ { return {{ __arr[_Idx]... }}; }
+
+
+ template<typename... _Tp>
+ using __array_t = __if_t<__no_type<__compose<__is_reference_wrapper,
+ std::remove_reference>::__call,
+ _Tp...>,
+ std::common_type<_Tp...>>;
+
+} // namespace __detail
+
+ /**
+ * @brief Convert a reference to a C-style array into a std::array.
+ *
+ * @tparam _Tp The element type of the array.
+ * @tparam _Num The size of the array.
+ */
+ template<typename _Tp, size_t _Num>
+ constexpr std::array<std::remove_cv_t<_Tp>, _Num>
+ to_array(_Tp (&__arr)[_Num])
+ {
+ return __detail::__to_array_helper(__arr,
+ std::make_index_sequence<_Num>());
+ }
+
+ /**
+ * @brief Make a std::array from a sequence of elements.
+ *
+ * @tparam _Tp The element type of the array.
+ * @tparam _Num The size of the array.
+ */
+ template<typename... _Tp>
+ constexpr auto
+ make_array(_Tp&&... __t)
+ -> std::array<__detail::__array_t<_Tp...>, sizeof...(_Tp)>
+ { return {{ std::forward<_Tp>(__t)... }}; }
+
+ /**
+ * @brief Make a std::array from a sequence of elements.
+ * The type of the first element determines the element type for the array.
+ *
+ * @tparam _Tp The element type of the array.
+ * @tparam _Num The size of the array.
+ */
+ template<typename _Vp, typename... _Tp>
+ constexpr auto
+ make_array(_Tp&&... __t)
+ -> std::array<_Vp, sizeof...(_Tp)>
+ { return {{ std::forward<_Tp>(__t)... }}; }
+
+} // namespace fundamentals_v2
+} // namespace experimental
+} // namespace std
+
+#endif // C++14
+
+#endif // _GLIBCXX_EXPERIMENTAL_ARRAY
Index: include/experimental/deque
===================================================================
--- include/experimental/deque (revision 0)
+++ include/experimental/deque (working copy)
@@ -0,0 +1,72 @@
+// <experimental/deque> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <deque>
+#include <algorithm>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_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 fundamentals_v2
+} // namespace experimental
+} // namespace std
+
+#endif // C++14
+
+#endif // _GLIBCXX_EXPERIMENTAL_DEQUE
Index: include/experimental/erase_if.tcc
===================================================================
--- include/experimental/erase_if.tcc (revision 0)
+++ include/experimental/erase_if.tcc (working copy)
@@ -0,0 +1,70 @@
+// <experimental/erase_if.tcc> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @file experimental/erase_if.tcc
+ * This is an internal header file, included by other library headers.
+ * Do not attempt to use it directly. @headername{erase_if}
+ */
+
+#ifndef _GLIBCXX_EXPERIMENTAL_ERASE_IF_TCC
+#define _GLIBCXX_EXPERIMENTAL_ERASE_IF_TCC 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+namespace std
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+
+ namespace __detail
+ {
+ template<typename _Container, typename _Predicate>
+ 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_TCC
Index: include/experimental/forward_list
===================================================================
--- include/experimental/forward_list (revision 0)
+++ include/experimental/forward_list (working copy)
@@ -0,0 +1,67 @@
+// <experimental/forward_list> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <forward_list>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Tp, typename _Alloc, typename _Predicate>
+ void
+ erase_if(forward_list<_Tp, _Alloc>& __cont, _Predicate __pred)
+ { __cont.remove_if(__pred); }
+
+ template<typename _Tp, typename _Alloc, typename _Up>
+ 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
Index: include/experimental/list
===================================================================
--- include/experimental/list (revision 0)
+++ include/experimental/list (working copy)
@@ -0,0 +1,68 @@
+// <experimental/list> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <list>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Tp, typename _Alloc, typename _Predicate>
+ void
+ erase_if(list<_Tp, _Alloc>& __cont, _Predicate __pred)
+ { __cont.remove_if(__pred); }
+
+ template<typename _Tp, typename _Alloc, typename _Up>
+ 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
Index: include/experimental/map
===================================================================
--- include/experimental/map (revision 0)
+++ include/experimental/map (working copy)
@@ -0,0 +1,68 @@
+// <experimental/map> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <map>
+#include <experimental/erase_if.tcc>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc,
+ typename _Predicate>
+ 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>
+ 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
Index: include/experimental/set
===================================================================
--- include/experimental/set (revision 0)
+++ include/experimental/set (working copy)
@@ -0,0 +1,68 @@
+// <experimental/set> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <set>
+#include <experimental/erase_if.tcc>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Key, typename _Compare, typename _Alloc,
+ typename _Predicate>
+ 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>
+ 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
Index: include/experimental/string
===================================================================
--- include/experimental/string (revision 0)
+++ include/experimental/string (working copy)
@@ -0,0 +1,73 @@
+// <experimental/string> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <string>
+#include <algorithm>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _CharT, typename _Traits, typename _Alloc,
+ typename _Predicate>
+ 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>
+ 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
Index: include/experimental/unordered_map
===================================================================
--- include/experimental/unordered_map (revision 0)
+++ include/experimental/unordered_map (working copy)
@@ -0,0 +1,70 @@
+// <experimental/unordered_map> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <unordered_map>
+#include <experimental/erase_if.tcc>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Key, typename _Tp, typename _Hash, typename _CPred,
+ typename _Alloc, typename _Predicate>
+ 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>
+ 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
Index: include/experimental/unordered_set
===================================================================
--- include/experimental/unordered_set (revision 0)
+++ include/experimental/unordered_set (working copy)
@@ -0,0 +1,70 @@
+// <experimental/unordered_set> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <unordered_set>
+#include <experimental/erase_if.tcc>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Key, typename _Hash, typename _CPred, typename _Alloc,
+ typename _Predicate>
+ void
+ erase_if(unordered_set<_Key, _Hash, _CPred, _Alloc>& __cont,
+ _Predicate __pred)
+ { __detail::__erase_nodes_if(__cont, __pred); }
+
+ template<typename _Key, typename _Hash, typename _CPred, typename _Alloc,
+ typename _Predicate>
+ 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
Index: include/experimental/vector
===================================================================
--- include/experimental/vector (revision 0)
+++ include/experimental/vector (working copy)
@@ -0,0 +1,72 @@
+// <experimental/vector> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <vector>
+#include <algorithm>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Tp, typename _Alloc, typename _Predicate>
+ 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>
+ 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
Index: testsuite/experimental/deque/erasure.cc
===================================================================
--- testsuite/experimental/deque/erasure.cc (revision 0)
+++ testsuite/experimental/deque/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/deque>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::deque<int> d{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase_if(d, is_odd);
+ std::deque<int> t{ 10, 12, 14, 18 };
+ VERIFY( d == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::deque<int> d{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase(d, 14);
+ std::deque<int> 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;
+}
Index: testsuite/experimental/forward_list/erasure.cc
===================================================================
--- testsuite/experimental/forward_list/erasure.cc (revision 0)
+++ testsuite/experimental/forward_list/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/forward_list>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::forward_list<int> fl{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase_if(fl, is_odd);
+ std::forward_list<int> t{ 10, 12, 14, 18 };
+ VERIFY( fl == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::forward_list<int> fl{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase(fl, 14);
+ std::forward_list<int> 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;
+}
Index: testsuite/experimental/list/erasure.cc
===================================================================
--- testsuite/experimental/list/erasure.cc (revision 0)
+++ testsuite/experimental/list/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/list>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::list<int> l{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase_if(l, is_odd);
+ std::list<int> t{ 10, 12, 14, 18 };
+ VERIFY( l == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::list<int> l{ 0, 11, 0, 0, 22, 33, 0, 0, 44, 0 };
+ std::experimental::erase(l, 0);
+ std::list<int> t{ 11, 22, 33, 44 };
+ VERIFY( l == t );
+ std::experimental::erase(l, 55);
+ VERIFY( l == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
Index: testsuite/experimental/map/erasure.cc
===================================================================
--- testsuite/experimental/map/erasure.cc (revision 0)
+++ testsuite/experimental/map/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/map>
+#include <testsuite_hooks.h>
+
+auto is_odd_pair = [](const std::pair<const int, std::string>& p)
+{
+ return p.first % 2 != 0;
+};
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::map<int, std::string> 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<int, std::string> t{ { 10, "A" }, { 12, "C" },
+ { 14, "D" }, { 18, "G" } };
+ VERIFY( m == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::multimap<int, std::string> 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<int, std::string> t{ { 20, "S" }, { 22, "U" },
+ { 22, "V" }, { 24, "Y" } };
+ VERIFY( mm == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
Index: testsuite/experimental/set/erasure.cc
===================================================================
--- testsuite/experimental/set/erasure.cc (revision 0)
+++ testsuite/experimental/set/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/set>
+#include <testsuite_hooks.h>
+
+auto is_odd = [](const int i) { return i % 2 != 0; };
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::set<int> s{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase_if(s, is_odd);
+ std::set<int> t{ 10, 12, 14, 18 };
+ VERIFY( s == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::multiset<int> ms{ 20, 21, 22, 22, 23, 23, 24, 25 };
+ std::experimental::erase_if(ms, is_odd);
+ std::multiset<int> t{ 20, 22, 22, 24 };
+ VERIFY( ms == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
Index: testsuite/experimental/string/erasure.cc
===================================================================
--- testsuite/experimental/string/erasure.cc (revision 0)
+++ testsuite/experimental/string/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/string>
+#include <testsuite_hooks.h>
+
+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;
+}
Index: testsuite/experimental/unordered_map/erasure.cc
===================================================================
--- testsuite/experimental/unordered_map/erasure.cc (revision 0)
+++ testsuite/experimental/unordered_map/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/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()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::unordered_map<int, std::string> 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<int, std::string> t{ { 10, "A" }, { 12, "C" },
+ { 14, "D" }, { 18, "G" } };
+ VERIFY( um == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::unordered_multimap<int, std::string> 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<int, std::string> t{ { 20, "S" }, { 22, "U" },
+ { 22, "V" }, { 24, "Y" } };
+ VERIFY( umm == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
Index: testsuite/experimental/unordered_set/erasure.cc
===================================================================
--- testsuite/experimental/unordered_set/erasure.cc (revision 0)
+++ testsuite/experimental/unordered_set/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/unordered_set>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::unordered_set<int> us{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase_if(us, is_odd);
+ std::unordered_set<int> 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<int> ums{ 20, 21, 22, 22, 23, 23, 24, 25 };
+ std::experimental::erase_if(ums, is_odd);
+ std::unordered_multiset<int> t{ 20, 22, 22, 24 };
+ VERIFY( ums == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
Index: testsuite/experimental/vector/erasure.cc
===================================================================
--- testsuite/experimental/vector/erasure.cc (revision 0)
+++ testsuite/experimental/vector/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/vector>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::vector<int> v{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase_if(v, is_odd);
+ std::vector<int> t{ 10, 12, 14, 18 };
+ VERIFY( v == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::vector<int> v{ 0, 11, 0, 0, 22, 33, 0, 0, 44, 0 };
+ std::experimental::erase(v, 0);
+ std::vector<int> t{ 11, 22, 33, 44 };
+ VERIFY( v == t );
+ std::experimental::erase(v, 55);
+ VERIFY( v == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
[-- Attachment #3: CL_erasure --]
[-- Type: text/plain, Size: 1062 bytes --]
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [libstdc++] Add uniform container erasure.
2015-04-30 11:40 [PATCH] [libstdc++] Add uniform container erasure Ed Smith-Rowland
@ 2015-04-30 12:47 ` Jonathan Wakely
2015-04-30 15:02 ` Ed Smith-Rowland
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2015-04-30 12:47 UTC (permalink / raw)
To: Ed Smith-Rowland; +Cc: gcc-patches, libstdc++
On 30/04/15 07:33 -0400, Ed Smith-Rowland wrote:
>This has been in me tree for a good while.
>
>It is fairly simple and adds C++ experimental container erasure.
And make_array, which isn't in the working paper yet, so I'd prefer to
leave that part out for now.
>Index: include/experimental/erase_if.tcc
>===================================================================
>--- include/experimental/erase_if.tcc (revision 0)
>+++ include/experimental/erase_if.tcc (working copy)
>@@ -0,0 +1,70 @@
>+// <experimental/erase_if.tcc> -*- 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
>+// <http://www.gnu.org/licenses/>.
>+
>+/** @file experimental/erase_if.tcc
>+ * This is an internal header file, included by other library headers.
>+ * Do not attempt to use it directly. @headername{erase_if}
The Doxygen @headername command tells users which header they are
supposed to include, rather than this one. Since there is no
<erase_if> header that's wrong. I'd just omit the @headername.
>+ */
>+
>+#ifndef _GLIBCXX_EXPERIMENTAL_ERASE_IF_TCC
>+#define _GLIBCXX_EXPERIMENTAL_ERASE_IF_TCC 1
>+
>+#pragma GCC system_header
>+
>+#if __cplusplus <= 201103L
>+# include <bits/c++14_warning.h>
>+#else
>+
>+namespace std
>+{
>+namespace experimental
>+{
>+inline namespace fundamentals_v2
>+{
>+
>+ namespace __detail
>+ {
>+ template<typename _Container, typename _Predicate>
>+ 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;
>+ }
>+ }
>+ }
This file doesn't really seem like a .tcc to me, it isn't providing
definitions of templates declared elsewhere (specifically in an
erase_if.h header).
Maybe we want an experimental/bits/ directory for this sort of thing
(which I could also use for the filesystem headers I'm about to
commit) but in the meanwhile I think just experimental/erase_if.h is a
better name.
OK for trunk with those changes (remove make_array, rename erase_if.tcc)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [libstdc++] Add uniform container erasure.
2015-04-30 12:47 ` Jonathan Wakely
@ 2015-04-30 15:02 ` Ed Smith-Rowland
2015-04-30 18:19 ` Daniel Krügler
0 siblings, 1 reply; 6+ messages in thread
From: Ed Smith-Rowland @ 2015-04-30 15:02 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 983 bytes --]
> And make_array, which isn't in the working paper yet, so I'd prefer to
> leave that part out for now.
D'oh! Sorry about that.. Removed.
> The Doxygen @headername command tells users which header they are
> supposed to include, rather than this one. Since there is no
> <erase_if> header that's wrong. I'd just omit the @headername.
Done.
> This file doesn't really seem like a .tcc to me, it isn't providing
> definitions of templates declared elsewhere (specifically in an
> erase_if.h header).
>
> Maybe we want an experimental/bits/ directory for this sort of thing
> (which I could also use for the filesystem headers I'm about to
> commit) but in the meanwhile I think just experimental/erase_if.h is a
> better name.
Done. (I didn't make experimental/bits - I'll move erase_if.h after you
add the bits directory).
> OK for trunk with those changes (remove make_array, rename erase_if.tcc)
Rebuilt, retested and committed as 222630.
Altered patch attached.
Thanks,
Ed
[-- Attachment #2: CL_erasure --]
[-- Type: text/plain, Size: 1063 bytes --]
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.
[-- Attachment #3: patch_erasure --]
[-- Type: text/plain, Size: 43265 bytes --]
Index: include/Makefile.am
===================================================================
--- include/Makefile.am (revision 222599)
+++ include/Makefile.am (working copy)
@@ -646,14 +646,24 @@
${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}/string_view.tcc \
${experimental_srcdir}/system_error \
- ${experimental_srcdir}/string_view.tcc \
${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)
Index: include/Makefile.in
===================================================================
--- include/Makefile.in (revision 222599)
+++ include/Makefile.in (working copy)
@@ -913,14 +913,24 @@
${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}/string_view.tcc \
${experimental_srcdir}/system_error \
- ${experimental_srcdir}/string_view.tcc \
${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.
Index: include/experimental/deque
===================================================================
--- include/experimental/deque (revision 0)
+++ include/experimental/deque (working copy)
@@ -0,0 +1,72 @@
+// <experimental/deque> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <deque>
+#include <algorithm>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_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 fundamentals_v2
+} // namespace experimental
+} // namespace std
+
+#endif // C++14
+
+#endif // _GLIBCXX_EXPERIMENTAL_DEQUE
Index: include/experimental/erase_if.h
===================================================================
--- include/experimental/erase_if.h (revision 0)
+++ include/experimental/erase_if.h (working copy)
@@ -0,0 +1,70 @@
+// <experimental/erase_if.h> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+namespace std
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+
+ namespace __detail
+ {
+ template<typename _Container, typename _Predicate>
+ 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
Index: include/experimental/forward_list
===================================================================
--- include/experimental/forward_list (revision 0)
+++ include/experimental/forward_list (working copy)
@@ -0,0 +1,67 @@
+// <experimental/forward_list> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <forward_list>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Tp, typename _Alloc, typename _Predicate>
+ void
+ erase_if(forward_list<_Tp, _Alloc>& __cont, _Predicate __pred)
+ { __cont.remove_if(__pred); }
+
+ template<typename _Tp, typename _Alloc, typename _Up>
+ 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
Index: include/experimental/list
===================================================================
--- include/experimental/list (revision 0)
+++ include/experimental/list (working copy)
@@ -0,0 +1,68 @@
+// <experimental/list> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <list>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Tp, typename _Alloc, typename _Predicate>
+ void
+ erase_if(list<_Tp, _Alloc>& __cont, _Predicate __pred)
+ { __cont.remove_if(__pred); }
+
+ template<typename _Tp, typename _Alloc, typename _Up>
+ 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
Index: include/experimental/map
===================================================================
--- include/experimental/map (revision 0)
+++ include/experimental/map (working copy)
@@ -0,0 +1,68 @@
+// <experimental/map> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <map>
+#include <experimental/erase_if.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Key, typename _Tp, typename _Compare, typename _Alloc,
+ typename _Predicate>
+ 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>
+ 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
Index: include/experimental/set
===================================================================
--- include/experimental/set (revision 0)
+++ include/experimental/set (working copy)
@@ -0,0 +1,68 @@
+// <experimental/set> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <set>
+#include <experimental/erase_if.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Key, typename _Compare, typename _Alloc,
+ typename _Predicate>
+ 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>
+ 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
Index: include/experimental/string
===================================================================
--- include/experimental/string (revision 0)
+++ include/experimental/string (working copy)
@@ -0,0 +1,73 @@
+// <experimental/string> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <string>
+#include <algorithm>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _CharT, typename _Traits, typename _Alloc,
+ typename _Predicate>
+ 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>
+ 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
Index: include/experimental/unordered_map
===================================================================
--- include/experimental/unordered_map (revision 0)
+++ include/experimental/unordered_map (working copy)
@@ -0,0 +1,70 @@
+// <experimental/unordered_map> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <unordered_map>
+#include <experimental/erase_if.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Key, typename _Tp, typename _Hash, typename _CPred,
+ typename _Alloc, typename _Predicate>
+ 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>
+ 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
Index: include/experimental/unordered_set
===================================================================
--- include/experimental/unordered_set (revision 0)
+++ include/experimental/unordered_set (working copy)
@@ -0,0 +1,70 @@
+// <experimental/unordered_set> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <unordered_set>
+#include <experimental/erase_if.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Key, typename _Hash, typename _CPred, typename _Alloc,
+ typename _Predicate>
+ void
+ erase_if(unordered_set<_Key, _Hash, _CPred, _Alloc>& __cont,
+ _Predicate __pred)
+ { __detail::__erase_nodes_if(__cont, __pred); }
+
+ template<typename _Key, typename _Hash, typename _CPred, typename _Alloc,
+ typename _Predicate>
+ 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
Index: include/experimental/vector
===================================================================
--- include/experimental/vector (revision 0)
+++ include/experimental/vector (working copy)
@@ -0,0 +1,72 @@
+// <experimental/vector> -*- 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
+// <http://www.gnu.org/licenses/>.
+
+/** @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 <bits/c++14_warning.h>
+#else
+
+#include <vector>
+#include <algorithm>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Tp, typename _Alloc, typename _Predicate>
+ 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>
+ 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
Index: testsuite/experimental/deque/erasure.cc
===================================================================
--- testsuite/experimental/deque/erasure.cc (revision 0)
+++ testsuite/experimental/deque/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/deque>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::deque<int> d{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase_if(d, is_odd);
+ std::deque<int> t{ 10, 12, 14, 18 };
+ VERIFY( d == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::deque<int> d{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase(d, 14);
+ std::deque<int> 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;
+}
Index: testsuite/experimental/forward_list/erasure.cc
===================================================================
--- testsuite/experimental/forward_list/erasure.cc (revision 0)
+++ testsuite/experimental/forward_list/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/forward_list>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::forward_list<int> fl{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase_if(fl, is_odd);
+ std::forward_list<int> t{ 10, 12, 14, 18 };
+ VERIFY( fl == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::forward_list<int> fl{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase(fl, 14);
+ std::forward_list<int> 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;
+}
Index: testsuite/experimental/list/erasure.cc
===================================================================
--- testsuite/experimental/list/erasure.cc (revision 0)
+++ testsuite/experimental/list/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/list>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::list<int> l{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase_if(l, is_odd);
+ std::list<int> t{ 10, 12, 14, 18 };
+ VERIFY( l == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::list<int> l{ 0, 11, 0, 0, 22, 33, 0, 0, 44, 0 };
+ std::experimental::erase(l, 0);
+ std::list<int> t{ 11, 22, 33, 44 };
+ VERIFY( l == t );
+ std::experimental::erase(l, 55);
+ VERIFY( l == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
Index: testsuite/experimental/map/erasure.cc
===================================================================
--- testsuite/experimental/map/erasure.cc (revision 0)
+++ testsuite/experimental/map/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/map>
+#include <testsuite_hooks.h>
+
+auto is_odd_pair = [](const std::pair<const int, std::string>& p)
+{
+ return p.first % 2 != 0;
+};
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::map<int, std::string> 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<int, std::string> t{ { 10, "A" }, { 12, "C" },
+ { 14, "D" }, { 18, "G" } };
+ VERIFY( m == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::multimap<int, std::string> 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<int, std::string> t{ { 20, "S" }, { 22, "U" },
+ { 22, "V" }, { 24, "Y" } };
+ VERIFY( mm == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
Index: testsuite/experimental/set/erasure.cc
===================================================================
--- testsuite/experimental/set/erasure.cc (revision 0)
+++ testsuite/experimental/set/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/set>
+#include <testsuite_hooks.h>
+
+auto is_odd = [](const int i) { return i % 2 != 0; };
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::set<int> s{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase_if(s, is_odd);
+ std::set<int> t{ 10, 12, 14, 18 };
+ VERIFY( s == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::multiset<int> ms{ 20, 21, 22, 22, 23, 23, 24, 25 };
+ std::experimental::erase_if(ms, is_odd);
+ std::multiset<int> t{ 20, 22, 22, 24 };
+ VERIFY( ms == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
Index: testsuite/experimental/string/erasure.cc
===================================================================
--- testsuite/experimental/string/erasure.cc (revision 0)
+++ testsuite/experimental/string/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/string>
+#include <testsuite_hooks.h>
+
+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;
+}
Index: testsuite/experimental/unordered_map/erasure.cc
===================================================================
--- testsuite/experimental/unordered_map/erasure.cc (revision 0)
+++ testsuite/experimental/unordered_map/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/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()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::unordered_map<int, std::string> 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<int, std::string> t{ { 10, "A" }, { 12, "C" },
+ { 14, "D" }, { 18, "G" } };
+ VERIFY( um == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::unordered_multimap<int, std::string> 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<int, std::string> t{ { 20, "S" }, { 22, "U" },
+ { 22, "V" }, { 24, "Y" } };
+ VERIFY( umm == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
Index: testsuite/experimental/unordered_set/erasure.cc
===================================================================
--- testsuite/experimental/unordered_set/erasure.cc (revision 0)
+++ testsuite/experimental/unordered_set/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/unordered_set>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::unordered_set<int> us{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase_if(us, is_odd);
+ std::unordered_set<int> 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<int> ums{ 20, 21, 22, 22, 23, 23, 24, 25 };
+ std::experimental::erase_if(ums, is_odd);
+ std::unordered_multiset<int> t{ 20, 22, 22, 24 };
+ VERIFY( ums == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
Index: testsuite/experimental/vector/erasure.cc
===================================================================
--- testsuite/experimental/vector/erasure.cc (revision 0)
+++ testsuite/experimental/vector/erasure.cc (working copy)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/vector>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test [[gnu::unused]] = true;
+
+ auto is_odd = [](const int i) { return i % 2 != 0; };
+
+ std::vector<int> v{ 10, 11, 12, 14, 15, 17, 18, 19 };
+ std::experimental::erase_if(v, is_odd);
+ std::vector<int> t{ 10, 12, 14, 18 };
+ VERIFY( v == t );
+}
+
+void
+test02()
+{
+ bool test [[gnu::unused]] = true;
+
+ std::vector<int> v{ 0, 11, 0, 0, 22, 33, 0, 0, 44, 0 };
+ std::experimental::erase(v, 0);
+ std::vector<int> t{ 11, 22, 33, 44 };
+ VERIFY( v == t );
+ std::experimental::erase(v, 55);
+ VERIFY( v == t );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [libstdc++] Add uniform container erasure.
2015-04-30 15:02 ` Ed Smith-Rowland
@ 2015-04-30 18:19 ` Daniel Krügler
2015-05-01 11:02 ` Ed Smith-Rowland
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Krügler @ 2015-04-30 18:19 UTC (permalink / raw)
To: Ed Smith-Rowland; +Cc: Jonathan Wakely, gcc-patches, libstdc++
2015-04-30 16:44 GMT+02:00 Ed Smith-Rowland <3dw4rd@verizon.net>:
>
>> And make_array, which isn't in the working paper yet, so I'd prefer to
>> leave that part out for now.
>
> D'oh! Sorry about that.. Removed.
>>
>> The Doxygen @headername command tells users which header they are
>> supposed to include, rather than this one. Since there is no
>> <erase_if> header that's wrong. I'd just omit the @headername.
>
> Done.
>>
>> This file doesn't really seem like a .tcc to me, it isn't providing
>> definitions of templates declared elsewhere (specifically in an
>> erase_if.h header).
>>
>> Maybe we want an experimental/bits/ directory for this sort of thing
>> (which I could also use for the filesystem headers I'm about to
>> commit) but in the meanwhile I think just experimental/erase_if.h is a
>> better name.
>
> Done. (I didn't make experimental/bits - I'll move erase_if.h after you add
> the bits directory).
>>
>> OK for trunk with those changes (remove make_array, rename erase_if.tcc)
>
> Rebuilt, retested and committed as 222630.
> Altered patch attached.
Shouldn't the "one-liner" forwarding function templates be declared as inline?
- Daniel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [libstdc++] Add uniform container erasure.
2015-04-30 18:19 ` Daniel Krügler
@ 2015-05-01 11:02 ` Ed Smith-Rowland
2015-05-01 11:05 ` Jonathan Wakely
0 siblings, 1 reply; 6+ messages in thread
From: Ed Smith-Rowland @ 2015-05-01 11:02 UTC (permalink / raw)
To: Daniel Krügler; +Cc: Jonathan Wakely, gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 208 bytes --]
On 04/30/2015 02:01 PM, Daniel Krügler wrote:
> Shouldn't the "one-liner" forwarding function templates be declared as
> inline? - Daniel
You are right.
This builds and tests clean on x86_64-linux.
OK?
[-- Attachment #2: CL_inl --]
[-- Type: text/plain, Size: 515 bytes --]
2015-05-01 Edward Smith-Rowland <3dw4rd@verizon.net>
Inline one-line erasure dispatch functions.
* include/experimental/forward_list (erase_if(), erase()): Inline.
* include/experimental/list (erase_if(), erase()): Inline.
* include/experimental/map (erase_if(*)): Inline.
* include/experimental/set (erase_if(*)): Inline.
* include/experimental/string (erase_if(), erase()): Inline.
* include/experimental/unordered_map (erase_if(*)): Inline.
* include/experimental/unordered_set (erase_if(*)): Inline.
[-- Attachment #3: patch_inl --]
[-- Type: text/plain, Size: 6133 bytes --]
Index: include/experimental/forward_list
===================================================================
--- include/experimental/forward_list (revision 222661)
+++ include/experimental/forward_list (working copy)
@@ -46,12 +46,13 @@
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, typename _Alloc, typename _Predicate>
- void
+ inline void
erase_if(forward_list<_Tp, _Alloc>& __cont, _Predicate __pred)
{ __cont.remove_if(__pred); }
template<typename _Tp, typename _Alloc, typename _Up>
- void erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value)
+ 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; });
Index: include/experimental/list
===================================================================
--- include/experimental/list (revision 222661)
+++ include/experimental/list (working copy)
@@ -46,12 +46,12 @@
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, typename _Alloc, typename _Predicate>
- void
+ inline void
erase_if(list<_Tp, _Alloc>& __cont, _Predicate __pred)
{ __cont.remove_if(__pred); }
template<typename _Tp, typename _Alloc, typename _Up>
- void
+ inline void
erase(list<_Tp, _Alloc>& __cont, const _Up& __value)
{
using __elem_type = typename list<_Tp, _Alloc>::value_type;
Index: include/experimental/map
===================================================================
--- include/experimental/map (revision 222661)
+++ include/experimental/map (working copy)
@@ -48,13 +48,13 @@
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc,
typename _Predicate>
- void
+ 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>
- void
+ inline void
erase_if(multimap<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
{ __detail::__erase_nodes_if(__cont, __pred); }
Index: include/experimental/set
===================================================================
--- include/experimental/set (revision 222661)
+++ include/experimental/set (working copy)
@@ -48,13 +48,13 @@
template<typename _Key, typename _Compare, typename _Alloc,
typename _Predicate>
- void
+ 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>
- void
+ inline void
erase_if(multiset<_Key, _Compare, _Alloc>& __cont, _Predicate __pred)
{ __detail::__erase_nodes_if(__cont, __pred); }
Index: include/experimental/string
===================================================================
--- include/experimental/string (revision 222661)
+++ include/experimental/string (working copy)
@@ -48,7 +48,7 @@
template<typename _CharT, typename _Traits, typename _Alloc,
typename _Predicate>
- void
+ inline void
erase_if(basic_string<_CharT, _Traits, _Alloc>& __cont, _Predicate __pred)
{
__cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred),
@@ -56,7 +56,7 @@
}
template<typename _CharT, typename _Traits, typename _Alloc, typename _Up>
- void
+ inline void
erase(basic_string<_CharT, _Traits, _Alloc>& __cont, const _Up& __value)
{
__cont.erase(std::remove(__cont.begin(), __cont.end(), __value),
Index: include/experimental/unordered_map
===================================================================
--- include/experimental/unordered_map (revision 222661)
+++ include/experimental/unordered_map (working copy)
@@ -48,7 +48,7 @@
template<typename _Key, typename _Tp, typename _Hash, typename _CPred,
typename _Alloc, typename _Predicate>
- void
+ inline void
erase_if(unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
_Predicate __pred)
{ __detail::__erase_nodes_if(__cont, __pred); }
@@ -55,7 +55,7 @@
template<typename _Key, typename _Tp, typename _Hash, typename _CPred,
typename _Alloc, typename _Predicate>
- void
+ inline void
erase_if(unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
_Predicate __pred)
{ __detail::__erase_nodes_if(__cont, __pred); }
Index: include/experimental/unordered_set
===================================================================
--- include/experimental/unordered_set (revision 222661)
+++ include/experimental/unordered_set (working copy)
@@ -48,7 +48,7 @@
template<typename _Key, typename _Hash, typename _CPred, typename _Alloc,
typename _Predicate>
- void
+ inline void
erase_if(unordered_set<_Key, _Hash, _CPred, _Alloc>& __cont,
_Predicate __pred)
{ __detail::__erase_nodes_if(__cont, __pred); }
@@ -55,7 +55,7 @@
template<typename _Key, typename _Hash, typename _CPred, typename _Alloc,
typename _Predicate>
- void
+ inline void
erase_if(unordered_multiset<_Key, _Hash, _CPred, _Alloc>& __cont,
_Predicate __pred)
{ __detail::__erase_nodes_if(__cont, __pred); }
Index: include/experimental/vector
===================================================================
--- include/experimental/vector (revision 222661)
+++ include/experimental/vector (working copy)
@@ -47,7 +47,7 @@
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, typename _Alloc, typename _Predicate>
- void
+ inline void
erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred)
{
__cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred),
@@ -55,7 +55,7 @@
}
template<typename _Tp, typename _Alloc, typename _Up>
- void
+ inline void
erase(vector<_Tp, _Alloc>& __cont, const _Up& __value)
{
__cont.erase(std::remove(__cont.begin(), __cont.end(), __value),
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [libstdc++] Add uniform container erasure.
2015-05-01 11:02 ` Ed Smith-Rowland
@ 2015-05-01 11:05 ` Jonathan Wakely
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2015-05-01 11:05 UTC (permalink / raw)
To: Ed Smith-Rowland; +Cc: Daniel Krügler, gcc-patches, libstdc++
On 01/05/15 07:01 -0400, Ed Smith-Rowland wrote:
>On 04/30/2015 02:01 PM, Daniel Krügler wrote:
>>Shouldn't the "one-liner" forwarding function templates be declared
>>as inline? - Daniel
>You are right.
>
>This builds and tests clean on x86_64-linux.
>
>OK?
Yes OK, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-05-01 11:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-30 11:40 [PATCH] [libstdc++] Add uniform container erasure Ed Smith-Rowland
2015-04-30 12:47 ` Jonathan Wakely
2015-04-30 15:02 ` Ed Smith-Rowland
2015-04-30 18:19 ` Daniel Krügler
2015-05-01 11:02 ` Ed Smith-Rowland
2015-05-01 11:05 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).