blob: 214c7dca433de226151b4e724dceafd2b26c1b10 [file] [log] [blame]
Eric Fiselierdba23b42016-05-07 03:09:55 +00001// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11// UNSUPPORTED: c++98, c++03
12
13// <experimental/unordered_set>
14
15// namespace std { namespace experimental { namespace pmr {
16// template <class V, class H = hash<V>, class P = equal_to<V> >
17// using unordered_set =
18// ::std::unordered_set<V, H, P, polymorphic_allocator<V>>
19//
20// template <class V, class H = hash<V>, class P = equal_to<V> >
21// using unordered_multiset =
22// ::std::unordered_multiset<V, H, P, polymorphic_allocator<V>>
23//
24// }}} // namespace std::experimental::pmr
25
26#include <experimental/unordered_set>
27#include <experimental/memory_resource>
28#include <type_traits>
29#include <cassert>
30
31namespace pmr = std::experimental::pmr;
32
33template <class T>
34struct MyHash : std::hash<T> {};
35
36template <class T>
37struct MyPred : std::equal_to<T> {};
38
39int main()
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, 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, int> m;
82 assert(m.get_allocator().resource() == pmr::get_default_resource());
83 }
84}