diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2022-05-19 23:38:23 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2022-05-19 23:38:23 +0100 |
commit | 8ccdc7ce33f5e7ca509e5b9f835ed4719db21ffd (patch) | |
tree | 35b201acf391285912ba2ad28de5baff3c197b13 /libstdc++-v3/testsuite | |
parent | d863ba23fb16122bb0547b0c678173be0d98f43c (diff) | |
download | gcc-8ccdc7ce33f5e7ca509e5b9f835ed4719db21ffd.tar.gz |
libstdc++: Ensure pmr aliases work without <memory_resource>
Currently the alias templates for std::pmr::vector, std::pmr::string
etc. are defined using a forward declaration for polymorphic_allocator.
This means you can't actually use the alias templates unless you also
include <memory_resource>. The rationale for that is that it's a fairly
large header, and most users don't need it. This isn't uncontroversial
though, and LWG 3681 questions whether it's even conforming.
This change adds a new <bits/memory_resource.h> header with the minimum
needed to use polymorphic_allocator and the std::pmr container aliases.
Including <memory_resource> is still necessary to use the program-wide
resource objects, or the pool resources or monotonic buffer resource.
libstdc++-v3/ChangeLog:
* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/bits/memory_resource.h: New file.
* include/std/deque: Include <bits/memory_resource.h>.
* include/std/forward_list: Likewise.
* include/std/list: Likewise.
* include/std/map: Likewise.
* include/std/memory_resource (pmr::memory_resource): Move to
new <bits/memory_resource.h> header.
(pmr::polymorphic_allocator): Likewise.
* include/std/regex: Likewise.
* include/std/set: Likewise.
* include/std/stacktrace: Likewise.
* include/std/string: Likewise.
* include/std/unordered_map: Likewise.
* include/std/unordered_set: Likewise.
* include/std/vector: Likewise.
* testsuite/21_strings/basic_string/types/pmr_typedefs.cc:
Remove <memory_resource> header and check construction.
* testsuite/23_containers/deque/types/pmr_typedefs.cc: Likewise.
* testsuite/23_containers/forward_list/pmr_typedefs.cc:
Likewise.
* testsuite/23_containers/list/pmr_typedefs.cc: Likewise.
* testsuite/23_containers/map/pmr_typedefs.cc: Likewise.
* testsuite/23_containers/multimap/pmr_typedefs.cc: Likewise.
* testsuite/23_containers/multiset/pmr_typedefs.cc: Likewise.
* testsuite/23_containers/set/pmr_typedefs.cc: Likewise.
* testsuite/23_containers/unordered_map/pmr_typedefs.cc:
Likewise.
* testsuite/23_containers/unordered_multimap/pmr_typedefs.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/pmr_typedefs.cc:
Likewise.
* testsuite/23_containers/unordered_set/pmr_typedefs.cc:
Likewise.
* testsuite/23_containers/vector/pmr_typedefs.cc: Likewise.
* testsuite/28_regex/match_results/pmr_typedefs.cc: Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/variadic-tuple.C: Qualify function to avoid ADL
finding std::make_tuple.
Diffstat (limited to 'libstdc++-v3/testsuite')
14 files changed, 28 insertions, 14 deletions
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 index 51bbfb0aba0..cabe59090af 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/types/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/types/pmr_typedefs.cc @@ -19,7 +19,8 @@ // { dg-require-effective-target cxx11_abi } #include <string> -#include <memory_resource> + +std::pmr::string s = "polly"; struct T : std::char_traits<char> { }; diff --git a/libstdc++-v3/testsuite/23_containers/deque/types/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/deque/types/pmr_typedefs.cc index f6493e8131e..c973d4f432c 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/types/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/types/pmr_typedefs.cc @@ -18,7 +18,8 @@ // { dg-do compile { target c++17 } } #include <deque> -#include <memory_resource> + +std::pmr::deque<int> c{1, 2, 3, 4}; struct 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 index 8559783881f..f66e53f62a8 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/pmr_typedefs.cc @@ -18,7 +18,8 @@ // { dg-do compile { target c++17 } } #include <forward_list> -#include <memory_resource> + +std::pmr::forward_list<int> c{1, 2, 3, 4}; struct X { }; diff --git a/libstdc++-v3/testsuite/23_containers/list/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/list/pmr_typedefs.cc index d6c408aa88f..3c5ef794720 100644 --- a/libstdc++-v3/testsuite/23_containers/list/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/23_containers/list/pmr_typedefs.cc @@ -18,7 +18,8 @@ // { dg-do compile { target c++17 } } #include <list> -#include <memory_resource> + +std::pmr::list<int> c{1, 2, 3, 4}; struct X { }; diff --git a/libstdc++-v3/testsuite/23_containers/map/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/map/pmr_typedefs.cc index cc82fcf5fc9..91602ccbc17 100644 --- a/libstdc++-v3/testsuite/23_containers/map/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/23_containers/map/pmr_typedefs.cc @@ -18,7 +18,8 @@ // { dg-do compile { target c++17 } } #include <map> -#include <memory_resource> + +std::pmr::map<int, int> c{{1,0}, {2,0}, {3,0}, {4,0}}; struct X { }; struct Y { }; diff --git a/libstdc++-v3/testsuite/23_containers/multimap/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/multimap/pmr_typedefs.cc index 2312ad680a2..13b0970a100 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/pmr_typedefs.cc @@ -18,7 +18,8 @@ // { dg-do compile { target c++17 } } #include <map> -#include <memory_resource> + +std::pmr::multimap<int, int> c{{1,0}, {2,0}, {3,0}, {4,0}}; struct X { }; struct Y { }; diff --git a/libstdc++-v3/testsuite/23_containers/multiset/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/multiset/pmr_typedefs.cc index 19e28023533..f1013b6efdc 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/pmr_typedefs.cc @@ -18,7 +18,8 @@ // { dg-do compile { target c++17 } } #include <set> -#include <memory_resource> + +std::pmr::multiset<int> c{1, 2, 3, 4}; struct X { }; struct Cmp { bool operator()(X, X) const { return false; } }; diff --git a/libstdc++-v3/testsuite/23_containers/set/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/set/pmr_typedefs.cc index a65d0719e52..4b70b984729 100644 --- a/libstdc++-v3/testsuite/23_containers/set/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/23_containers/set/pmr_typedefs.cc @@ -18,7 +18,8 @@ // { dg-do compile { target c++17 } } #include <set> -#include <memory_resource> + +std::pmr::set<int> c{1, 2, 3, 4}; struct X { }; struct Cmp { bool operator()(X, X) const { return false; } }; diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/pmr_typedefs.cc index 7c00633bf1c..d8e17139f05 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/pmr_typedefs.cc @@ -18,7 +18,8 @@ // { dg-do compile { target c++17 } } #include <unordered_map> -#include <memory_resource> + +std::pmr::unordered_map<int, int> c{{1,0}, {2,0}, {3,0}, {4,0}}; struct X { }; struct 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 index 51d598e7e25..6dfe1d5b8bd 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/pmr_typedefs.cc @@ -18,7 +18,8 @@ // { dg-do compile { target c++17 } } #include <unordered_map> -#include <memory_resource> + +std::pmr::unordered_multimap<int, int> c{{1,0}, {2,0}, {3,0}, {4,0}}; struct X { }; struct 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 index f5b9d6c0282..4deeb710686 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/pmr_typedefs.cc @@ -18,7 +18,8 @@ // { dg-do compile { target c++17 } } #include <unordered_set> -#include <memory_resource> + +std::pmr::unordered_multiset<int> c{1, 2, 3, 4}; struct X { }; struct Hash { std::size_t operator()(X) const { return 0; } }; diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/pmr_typedefs.cc index 5fe33e880f9..4736cfff86f 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/pmr_typedefs.cc @@ -18,7 +18,8 @@ // { dg-do compile { target c++17 } } #include <unordered_set> -#include <memory_resource> + +std::pmr::unordered_set<int> c{1, 2, 3, 4}; struct X { }; struct Hash { std::size_t operator()(X) const { return 0; } }; diff --git a/libstdc++-v3/testsuite/23_containers/vector/pmr_typedefs.cc b/libstdc++-v3/testsuite/23_containers/vector/pmr_typedefs.cc index 0fbc32bb185..f4969e3364e 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/pmr_typedefs.cc @@ -18,7 +18,8 @@ // { dg-do compile { target c++17 } } #include <vector> -#include <memory_resource> + +std::pmr::vector<int> c{1, 2, 3, 4}; struct 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 index b8c22d03a17..5ff4c771a6c 100644 --- a/libstdc++-v3/testsuite/28_regex/match_results/pmr_typedefs.cc +++ b/libstdc++-v3/testsuite/28_regex/match_results/pmr_typedefs.cc @@ -20,7 +20,8 @@ // { dg-require-effective-target cxx11_abi } #include <regex> -#include <memory_resource> + +std::pmr::match_results<const char*> m; struct X; static_assert(std::is_same_v<std::pmr::match_results<X*>, |