1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // UNSUPPORTED: c++03
10
11 // <experimental/unordered_set>
12
13 // namespace std { namespace experimental { namespace pmr {
14 // template <class V, class H = hash<V>, class P = equal_to<V> >
15 // using unordered_set =
16 // ::std::unordered_set<V, H, P, polymorphic_allocator<V>>
17 //
18 // template <class V, class H = hash<V>, class P = equal_to<V> >
19 // using unordered_multiset =
20 // ::std::unordered_multiset<V, H, P, polymorphic_allocator<V>>
21 //
22 // }}} // namespace std::experimental::pmr
23
24 #include <experimental/unordered_set>
25 #include <experimental/memory_resource>
26 #include <type_traits>
27 #include <cassert>
28
29 #include "test_macros.h"
30
31 namespace pmr = std::experimental::pmr;
32
33 template <class T>
34 struct MyHash : std::hash<T> {};
35
36 template <class T>
37 struct MyPred : std::equal_to<T> {};
38
main(int,char **)39 int main(int, char**)
40 {
41 using V = char;
42 using DH = std::hash<V>;
43 using MH = MyHash<V>;
44 using DP = std::equal_to<V>;
45 using MP = MyPred<V>;
46 {
47 using StdSet = std::unordered_set<V, DH, DP, pmr::polymorphic_allocator<V>>;
48 using PmrSet = pmr::unordered_set<V>;
49 static_assert(std::is_same<StdSet, PmrSet>::value, "");
50 }
51 {
52 using StdSet = std::unordered_set<V, MH, DP, pmr::polymorphic_allocator<V>>;
53 using PmrSet = pmr::unordered_set<V, MH>;
54 static_assert(std::is_same<StdSet, PmrSet>::value, "");
55 }
56 {
57 using StdSet = std::unordered_set<V, MH, MP, pmr::polymorphic_allocator<V>>;
58 using PmrSet = pmr::unordered_set<V, MH, MP>;
59 static_assert(std::is_same<StdSet, PmrSet>::value, "");
60 }
61 {
62 pmr::unordered_set<int> m;
63 assert(m.get_allocator().resource() == pmr::get_default_resource());
64 }
65 {
66 using StdSet = std::unordered_multiset<V, DH, DP, pmr::polymorphic_allocator<V>>;
67 using PmrSet = pmr::unordered_multiset<V>;
68 static_assert(std::is_same<StdSet, PmrSet>::value, "");
69 }
70 {
71 using StdSet = std::unordered_multiset<V, MH, DP, pmr::polymorphic_allocator<V>>;
72 using PmrSet = pmr::unordered_multiset<V, MH>;
73 static_assert(std::is_same<StdSet, PmrSet>::value, "");
74 }
75 {
76 using StdSet = std::unordered_multiset<V, MH, MP, pmr::polymorphic_allocator<V>>;
77 using PmrSet = pmr::unordered_multiset<V, MH, MP>;
78 static_assert(std::is_same<StdSet, PmrSet>::value, "");
79 }
80 {
81 pmr::unordered_multiset<int> m;
82 assert(m.get_allocator().resource() == pmr::get_default_resource());
83 }
84
85 return 0;
86 }
87