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