Define aliases for containers using polymorphic_allocator
authorJonathan Wakely <jwakely@redhat.com>
Thu, 9 Aug 2018 23:25:53 +0000 (00:25 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 9 Aug 2018 23:25:53 +0000 (00:25 +0100)
These aliases are placed in the top-level header, e.g. <vector> not
<bits/stl_vector.h>. This ensures that they refer to whichever of
std::vector or __debug::vector or __profile::vector is in use when the
header is included.

* include/std/deque (std::pmr::deque): Declare alias.
* include/std/forward_list (std::pmr::forward_list): Likewise.
* include/std/list (std::pmr::list): Likewise.
* include/std/map (std::pmr::map, std::pmr::multimap): Likewise.
* include/std/regex (std::pmr::match_results, std::pmr::cmatch)
(std::pmr::smatch, std::pmr::wcmatch, std::pmr::wsmatch): Likewise.
* include/std/set (std::pmr::set, std::pmr::multiset): Likewise.
* include/std/string (std::pmr::basic_string, std::pmr::string)
(std::pmr::u16string, std::pmr::u32string, std::pmr::wstring):
Likewise.
* include/std/unordered_map (std::pmr::unordered_map)
(std::pmr::unordered_multimap): Likewise.
* include/std/unordered_set (std::pmr::unordered_set)
(std::pmr::unordered_multiset): Likewise.
* include/std/vector (std::pmr::vector): Likewise.
* testsuite/21_strings/basic_string/types/pmr_typedefs.cc: New test.
* testsuite/23_containers/deque/types/pmr_typedefs.cc: New test.
* testsuite/23_containers/forward_list/pmr_typedefs.cc: New test.
* testsuite/23_containers/list/pmr_typedefs.cc: New test.
* testsuite/23_containers/map/pmr_typedefs.cc: New test.
* testsuite/23_containers/multimap/pmr_typedefs.cc: New test.
* testsuite/23_containers/multiset/pmr_typedefs.cc: New test.
* testsuite/23_containers/set/pmr_typedefs.cc: New test.
* testsuite/23_containers/unordered_map/pmr_typedefs.cc: New test.
* testsuite/23_containers/unordered_multimap/pmr_typedefs.cc: New
test.
* testsuite/23_containers/unordered_multiset/pmr_typedefs.cc: New
test.
* testsuite/23_containers/unordered_set/pmr_typedefs.cc: New test.
* testsuite/23_containers/vector/pmr_typedefs.cc: New test.
* testsuite/28_regex/match_results/pmr_typedefs.cc: New test.

From-SVN: r263456

25 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/std/deque
libstdc++-v3/include/std/forward_list
libstdc++-v3/include/std/list
libstdc++-v3/include/std/map
libstdc++-v3/include/std/regex
libstdc++-v3/include/std/set
libstdc++-v3/include/std/string
libstdc++-v3/include/std/unordered_map
libstdc++-v3/include/std/unordered_set
libstdc++-v3/include/std/vector
libstdc++-v3/testsuite/21_strings/basic_string/types/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/deque/types/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/list/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/map/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multimap/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multiset/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/set/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_map/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multimap/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multiset/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/pmr_typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/28_regex/match_results/pmr_typedefs.cc [new file with mode: 0644]

index 20e03a1fdf5a083f4df04695a99e4c191f8e2ee0..1b61ec79360f3b91d4b48febc91b70a5e42cbbde 100644 (file)
@@ -1,3 +1,37 @@
+2018-08-10  Jonathan Wakely  <jwakely@redhat.com>
+
+       * include/std/deque (std::pmr::deque): Declare alias.
+       * include/std/forward_list (std::pmr::forward_list): Likewise.
+       * include/std/list (std::pmr::list): Likewise.
+       * include/std/map (std::pmr::map, std::pmr::multimap): Likewise.
+       * include/std/regex (std::pmr::match_results, std::pmr::cmatch)
+       (std::pmr::smatch, std::pmr::wcmatch, std::pmr::wsmatch): Likewise.
+       * include/std/set (std::pmr::set, std::pmr::multiset): Likewise.
+       * include/std/string (std::pmr::basic_string, std::pmr::string)
+       (std::pmr::u16string, std::pmr::u32string, std::pmr::wstring):
+       Likewise.
+       * include/std/unordered_map (std::pmr::unordered_map)
+       (std::pmr::unordered_multimap): Likewise.
+       * include/std/unordered_set (std::pmr::unordered_set)
+       (std::pmr::unordered_multiset): Likewise.
+       * include/std/vector (std::pmr::vector): Likewise.
+       * testsuite/21_strings/basic_string/types/pmr_typedefs.cc: New test.
+       * testsuite/23_containers/deque/types/pmr_typedefs.cc: New test.
+       * testsuite/23_containers/forward_list/pmr_typedefs.cc: New test.
+       * testsuite/23_containers/list/pmr_typedefs.cc: New test.
+       * testsuite/23_containers/map/pmr_typedefs.cc: New test.
+       * testsuite/23_containers/multimap/pmr_typedefs.cc: New test.
+       * testsuite/23_containers/multiset/pmr_typedefs.cc: New test.
+       * testsuite/23_containers/set/pmr_typedefs.cc: New test.
+       * testsuite/23_containers/unordered_map/pmr_typedefs.cc: New test.
+       * testsuite/23_containers/unordered_multimap/pmr_typedefs.cc: New
+       test.
+       * testsuite/23_containers/unordered_multiset/pmr_typedefs.cc: New
+       test.
+       * testsuite/23_containers/unordered_set/pmr_typedefs.cc: New test.
+       * testsuite/23_containers/vector/pmr_typedefs.cc: New test.
+       * testsuite/28_regex/match_results/pmr_typedefs.cc: New test.
+
 2018-08-08  François Dumont  <fdumont@gcc.gnu.org>
 
        * include/bits/stl_algo.h
index 896ec8aade0c2001e43f3ab654c9fa72c6b39cfc..d2c75f1f07825b2faa3968782b9c5a8914bebf91 100644 (file)
 # include <profile/deque>
 #endif
 
+#if __cplusplus >= 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  namespace pmr
+  {
+    template<typename _Tp> class polymorphic_allocator;
+    template<typename _Tp>
+      using deque = std::deque<_Tp, polymorphic_allocator<_Tp>>;
+  } // namespace pmr
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++17
+
 #endif /* _GLIBCXX_DEQUE */
index fd4cfe531793c0b45b6f0a51ba6cb97cfcb71a2e..00b41354c7d79f0b646a1fa4d7281c4f081c711a 100644 (file)
 # include <profile/forward_list>
 #endif
 
+#if __cplusplus >= 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  namespace pmr
+  {
+    template<typename _Tp> class polymorphic_allocator;
+    template<typename _Tp>
+      using forward_list = std::forward_list<_Tp, polymorphic_allocator<_Tp>>;
+  } // namespace pmr
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++17
 #endif // C++11
 
 #endif // _GLIBCXX_FORWARD_LIST
index 6ba1363b84da9de0fd279edcfecbec902dd85d72..555371ffb769a8d8278c051c2ec96bb40c1b8034 100644 (file)
 # include <profile/list>
 #endif
 
+#if __cplusplus >= 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  namespace pmr
+  {
+    template<typename _Tp> class polymorphic_allocator;
+    template<typename _Tp>
+      using list = std::list<_Tp, polymorphic_allocator<_Tp>>;
+  } // namespace pmr
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++17
 #endif /* _GLIBCXX_LIST */
-
index 5c429f00c0bdf4068807a652327866185273dd03..84f8cdb701dfd76afe5e40e174680863acac727b 100644 (file)
 # include <profile/map>
 #endif
 
+#if __cplusplus >= 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  namespace pmr
+  {
+    template<typename _Tp> class polymorphic_allocator;
+    template<typename _Key, typename _Tp, typename _Cmp = std::less<_Key>>
+      using map
+       = std::map<_Key, _Tp, _Cmp,
+                  polymorphic_allocator<pair<const _Key, _Tp>>>;
+    template<typename _Key, typename _Tp, typename _Cmp = std::less<_Key>>
+      using multimap
+       = std::multimap<_Key, _Tp, _Cmp,
+                       polymorphic_allocator<pair<const _Key, _Tp>>>;
+  } // namespace pmr
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++17
+
 #endif /* _GLIBCXX_MAP */
index 7e4564a3783f325e0c942f96c6e931d903a2c098..f0dfa3f68ab9b2c449c4d7528ca62b26d60d5e94 100644 (file)
 #include <bits/regex.h>
 #include <bits/regex_executor.h>
 
+#if __cplusplus >= 201703L
+#include <memory_resource>
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  namespace pmr {
+    template<typename _Tp> class polymorphic_allocator;
+    template<typename _BidirectionalIterator>
+      using match_results
+       = std::match_results<_BidirectionalIterator, polymorphic_allocator<
+                               sub_match<_BidirectionalIterator>>>;
+    using cmatch  = match_results<const char*>;
+    using smatch  = match_results<string::const_iterator>;
+#ifdef _GLIBCXX_USE_WCHAR_T
+    using wcmatch = match_results<const wchar_t*>;
+    using wsmatch = match_results<wstring::const_iterator>;
+#endif
+  } // namespace pmr
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++17
 #endif // C++11
 
 #endif // _GLIBCXX_REGEX
index 732c6d33f08c2a8156838ec054a8e9f67a1b2feb..dd41b2f19113e97ce401ef2ef91add4c783f7a9d 100644 (file)
 # include <profile/set>
 #endif
 
+#if __cplusplus >= 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  namespace pmr
+  {
+    template<typename _Tp> class polymorphic_allocator;
+    template<typename _Key, typename _Cmp = std::less<_Key>>
+      using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>;
+    template<typename _Key, typename _Cmp = std::less<_Key>>
+      using multiset = std::multiset<_Key, _Cmp, polymorphic_allocator<_Key>>;
+  } // namespace pmr
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++17
+
 #endif /* _GLIBCXX_SET */
index 2fceead30a8c3fdffb05fbe36415a2be2eef0d80..d3cc03aa179a17cfcf8c23664c0b6cb40a5fb395 100644 (file)
 #include <bits/basic_string.h>
 #include <bits/basic_string.tcc>
 
+#if __cplusplus >= 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  namespace pmr {
+    template<typename _Tp> class polymorphic_allocator;
+    template<typename _CharT, typename _Traits = char_traits<_CharT>>
+      using basic_string = std::basic_string<_CharT, _Traits,
+                                            polymorphic_allocator<_CharT>>;
+    using string    = basic_string<char>;
+    using u16string = basic_string<char16_t>;
+    using u32string = basic_string<char32_t>;
+#ifdef _GLIBCXX_USE_WCHAR_T
+    using wstring   = basic_string<wchar_t>;
+#endif
+  } // namespace pmr
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++17
+
 #endif /* _GLIBCXX_STRING */
index 85840fc49cde6a5e27c8c2a0f4589a3dfc25a6d6..fc1b1e3c71cc90433563b2bf9808994090fbfef5 100644 (file)
 # include <profile/unordered_map>
 #endif
 
+#if __cplusplus >= 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  namespace pmr
+  {
+    template<typename _Tp> class polymorphic_allocator;
+    template<typename _Key, typename _Tp, typename _Hash = std::hash<_Key>,
+            typename _Pred = std::equal_to<_Key>>
+      using unordered_map
+       = std::unordered_map<_Key, _Tp, _Hash, _Pred,
+                            polymorphic_allocator<pair<const _Key, _Tp>>>;
+    template<typename _Key, typename _Tp, typename _Hash = std::hash<_Key>,
+            typename _Pred = std::equal_to<_Key>>
+      using unordered_multimap
+       = std::unordered_multimap<_Key, _Tp, _Hash, _Pred,
+                                 polymorphic_allocator<pair<const _Key, _Tp>>>;
+  } // namespace pmr
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++17
 #endif // C++11
 
 #endif // _GLIBCXX_UNORDERED_MAP
index 0593fbd1b61d29363134917f1104194c52b8266b..8c04669a46e681fc2de8a8146300e498313d1ed6 100644 (file)
 #ifdef _GLIBCXX_PROFILE
 # include <profile/unordered_set>
 #endif
+
+#if __cplusplus >= 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  namespace pmr
+  {
+    template<typename _Tp> class polymorphic_allocator;
+    template<typename _Key, typename _Hash = std::hash<_Key>,
+            typename _Pred = std::equal_to<_Key>>
+      using unordered_set
+       = std::unordered_set<_Key, _Hash, _Pred,
+                            polymorphic_allocator<_Key>>;
+    template<typename _Key, typename _Hash = std::hash<_Key>,
+            typename _Pred = std::equal_to<_Key>>
+      using unordered_multiset
+       = std::unordered_multiset<_Key, _Hash, _Pred,
+                                 polymorphic_allocator<_Key>>;
+  } // namespace pmr
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++17
 #endif // C++11
 
 #endif // _GLIBCXX_UNORDERED_SET
index e03e50f9c9a16b6b6f39fa74dca413c66ef5fc2b..2a421c631f1823819b9ca4bcced2835a9b6f69c0 100644 (file)
 # include <profile/vector>
 #endif
 
-#endif /* _GLIBCXX_VECTOR */
+#if __cplusplus >= 201703L
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  namespace pmr {
+    template<typename _Tp> class polymorphic_allocator;
+    template<typename _Tp>
+      using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
+  } // namespace pmr
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // C++17
 
+#endif /* _GLIBCXX_VECTOR */
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/types/pmr_typedefs.cc b/libstdc++-v3/testsuite/21_strings/basic_string/types/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..d20fc42
--- /dev/null
@@ -0,0 +1,52 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <string>
+#include <memory_resource>
+
+struct T : std::char_traits<char> { };
+
+static_assert(std::is_same_v<std::pmr::basic_string<char>,
+    std::basic_string<char, std::char_traits<char>,
+                     std::pmr::polymorphic_allocator<char>>>);
+static_assert(std::is_same_v<std::pmr::basic_string<char, T>,
+    std::basic_string<char, T, std::pmr::polymorphic_allocator<char>>>);
+
+static_assert(std::is_same_v<std::pmr::string,
+    std::basic_string<char, std::char_traits<char>,
+                     std::pmr::polymorphic_allocator<char>>>);
+static_assert(std::is_same_v<std::pmr::u16string,
+    std::basic_string<char16_t, std::char_traits<char16_t>,
+                     std::pmr::polymorphic_allocator<char16_t>>>);
+static_assert(std::is_same_v<std::pmr::u32string,
+    std::basic_string<char32_t, std::char_traits<char32_t>,
+                     std::pmr::polymorphic_allocator<char32_t>>>);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+static_assert(std::is_same_v<std::pmr::basic_string<wchar_t>,
+    std::basic_string<wchar_t, std::char_traits<wchar_t>,
+                     std::pmr::polymorphic_allocator<wchar_t>>>);
+static_assert(std::is_same_v<std::pmr::basic_string<wchar_t, T>,
+    std::basic_string<wchar_t, T, std::pmr::polymorphic_allocator<wchar_t>>>);
+
+static_assert(std::is_same_v<std::pmr::wstring,
+    std::basic_string<wchar_t, std::char_traits<wchar_t>,
+                     std::pmr::polymorphic_allocator<wchar_t>>>);
+#endif
diff --git a/libstdc++-v3/testsuite/23_containers/deque/types/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/deque/types/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..cd51626
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <deque>
+#include <memory_resource>
+
+struct X { };
+
+static_assert(std::is_same_v<std::pmr::deque<X>,
+    std::deque<X, std::pmr::polymorphic_allocator<X>>>);
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/forward_list/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..7bf61fa
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <forward_list>
+#include <memory_resource>
+
+struct X { };
+
+static_assert(std::is_same_v<std::pmr::forward_list<X>,
+    std::forward_list<X, std::pmr::polymorphic_allocator<X>>>);
diff --git a/libstdc++-v3/testsuite/23_containers/list/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/list/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..3359295
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <list>
+#include <memory_resource>
+
+struct X { };
+
+static_assert(std::is_same_v<std::pmr::list<X>,
+    std::list<X, std::pmr::polymorphic_allocator<X>>>);
diff --git a/libstdc++-v3/testsuite/23_containers/map/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/map/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..1a49272
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <map>
+#include <memory_resource>
+
+struct X { };
+struct Y { };
+struct Cmp { bool operator()(X, X) const { return false; } };
+
+static_assert(std::is_same_v<std::pmr::map<X, Y>,
+    std::map<X, Y, std::less<X>,
+            std::pmr::polymorphic_allocator<std::pair<const X, Y>>>>);
+static_assert(std::is_same_v<std::pmr::map<X, Y, Cmp>,
+    std::map<X, Y, Cmp,
+            std::pmr::polymorphic_allocator<std::pair<const X, Y>>>>);
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/multimap/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..f1dc01e
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <map>
+#include <memory_resource>
+
+struct X { };
+struct Y { };
+struct Cmp { bool operator()(X, X) const { return false; } };
+
+static_assert(std::is_same_v<std::pmr::multimap<X, Y>,
+    std::multimap<X, Y, std::less<X>,
+                 std::pmr::polymorphic_allocator<std::pair<const X, Y>>>>);
+static_assert(std::is_same_v<std::pmr::multimap<X, Y, Cmp>,
+    std::multimap<X, Y, Cmp,
+                 std::pmr::polymorphic_allocator<std::pair<const X, Y>>>>);
diff --git a/libstdc++-v3/testsuite/23_containers/multiset/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/multiset/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..224d882
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <set>
+#include <memory_resource>
+
+struct X { };
+struct Cmp { bool operator()(X, X) const { return false; } };
+
+static_assert(std::is_same_v<std::pmr::multiset<X>,
+    std::multiset<X, std::less<X>, std::pmr::polymorphic_allocator<X>>>);
+static_assert(std::is_same_v<std::pmr::multiset<X, Cmp>,
+    std::multiset<X, Cmp, std::pmr::polymorphic_allocator<X>>>);
diff --git a/libstdc++-v3/testsuite/23_containers/set/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/set/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..f041c85
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <set>
+#include <memory_resource>
+
+struct X { };
+struct Cmp { bool operator()(X, X) const { return false; } };
+
+static_assert(std::is_same_v<std::pmr::set<X>,
+    std::set<X, std::less<X>, std::pmr::polymorphic_allocator<X>>>);
+static_assert(std::is_same_v<std::pmr::set<X, Cmp>,
+    std::set<X, Cmp, std::pmr::polymorphic_allocator<X>>>);
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..c628539
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <unordered_map>
+#include <memory_resource>
+
+struct X { };
+struct Y { };
+struct Hash { std::size_t operator()(X) const { return 0; } };
+struct Eq { bool operator()(X, X) const { return true; } };
+
+static_assert(std::is_same_v<std::pmr::unordered_map<X, Y>,
+    std::unordered_map<X, Y, std::hash<X>, std::equal_to<X>,
+      std::pmr::polymorphic_allocator<std::pair<const X, Y>>>>);
+static_assert(std::is_same_v<std::pmr::unordered_map<X, Y, Hash>,
+    std::unordered_map<X, Y, Hash, std::equal_to<X>,
+      std::pmr::polymorphic_allocator<std::pair<const X, Y>>>>);
+static_assert(std::is_same_v<std::pmr::unordered_map<X, Y, Hash, Eq>,
+    std::unordered_map<X, Y, Hash, Eq,
+      std::pmr::polymorphic_allocator<std::pair<const X, Y>>>>);
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..849b5ab
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <unordered_map>
+#include <memory_resource>
+
+struct X { };
+struct Y { };
+struct Hash { std::size_t operator()(X) const { return 0; } };
+struct Eq { bool operator()(X, X) const { return true; } };
+
+static_assert(std::is_same_v<std::pmr::unordered_multimap<X, Y>,
+    std::unordered_multimap<X, Y, std::hash<X>, std::equal_to<X>,
+      std::pmr::polymorphic_allocator<std::pair<const X, Y>>>>);
+static_assert(std::is_same_v<std::pmr::unordered_multimap<X, Y, Hash>,
+    std::unordered_multimap<X, Y, Hash, std::equal_to<X>,
+      std::pmr::polymorphic_allocator<std::pair<const X, Y>>>>);
+static_assert(std::is_same_v<std::pmr::unordered_multimap<X, Y, Hash, Eq>,
+    std::unordered_multimap<X, Y, Hash, Eq,
+      std::pmr::polymorphic_allocator<std::pair<const X, Y>>>>);
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..c4eaaf5
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <unordered_set>
+#include <memory_resource>
+
+struct X { };
+struct Hash { std::size_t operator()(X) const { return 0; } };
+struct Eq { bool operator()(X, X) const { return true; } };
+
+static_assert(std::is_same_v<std::pmr::unordered_multiset<X>,
+    std::unordered_multiset<X, std::hash<X>, std::equal_to<X>,
+      std::pmr::polymorphic_allocator<X>>>);
+static_assert(std::is_same_v<std::pmr::unordered_multiset<X, Hash>,
+    std::unordered_multiset<X, Hash, std::equal_to<X>,
+      std::pmr::polymorphic_allocator<X>>>);
+static_assert(std::is_same_v<std::pmr::unordered_multiset<X, Hash, Eq>,
+    std::unordered_multiset<X, Hash, Eq,
+      std::pmr::polymorphic_allocator<X>>>);
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..ecd3823
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <unordered_set>
+#include <memory_resource>
+
+struct X { };
+struct Hash { std::size_t operator()(X) const { return 0; } };
+struct Eq { bool operator()(X, X) const { return true; } };
+
+static_assert(std::is_same_v<std::pmr::unordered_set<X>,
+    std::unordered_set<X, std::hash<X>, std::equal_to<X>,
+      std::pmr::polymorphic_allocator<X>>>);
+static_assert(std::is_same_v<std::pmr::unordered_set<X, Hash>,
+    std::unordered_set<X, Hash, std::equal_to<X>,
+      std::pmr::polymorphic_allocator<X>>>);
+static_assert(std::is_same_v<std::pmr::unordered_set<X, Hash, Eq>,
+    std::unordered_set<X, Hash, Eq,
+      std::pmr::polymorphic_allocator<X>>>);
diff --git a/libstdc++-v3/testsuite/23_containers/vector/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/vector/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..d2f60fe
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <vector>
+#include <memory_resource>
+
+struct X { };
+
+static_assert(std::is_same_v<std::pmr::vector<X>,
+    std::vector<X, std::pmr::polymorphic_allocator<X>>>);
diff --git a/libstdc++-v3/testsuite/28_regex/match_results/pmr_typedefs.cc b/libstdc++-v3/testsuite/28_regex/match_results/pmr_typedefs.cc
new file mode 100644 (file)
index 0000000..23aef39
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <regex>
+#include <memory_resource>
+
+struct X;
+static_assert(std::is_same_v<std::pmr::match_results<X*>,
+    std::match_results<X*,
+      std::pmr::polymorphic_allocator<std::sub_match<X*>>>>);
+
+static_assert(std::is_same_v<std::pmr::cmatch,
+    std::match_results<const char*,
+      std::pmr::polymorphic_allocator<std::sub_match<const char*>>>>);
+static_assert(std::is_same_v<std::pmr::smatch,
+    std::match_results<std::pmr::string::const_iterator,
+      std::pmr::polymorphic_allocator<
+       std::sub_match<std::pmr::string::const_iterator>>>>);
+#ifdef _GLIBCXX_USE_WCHAR_T
+static_assert(std::is_same_v<std::pmr::wcmatch,
+    std::match_results<const wchar_t*,
+      std::pmr::polymorphic_allocator<std::sub_match<const wchar_t*>>>>);
+static_assert(std::is_same_v<std::pmr::wsmatch,
+    std::match_results<std::pmr::wstring::const_iterator,
+      std::pmr::polymorphic_allocator<
+       std::sub_match<std::pmr::wstring::const_iterator>>>>);
+#endif