1 // -*- 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 // REQUIRES: c++experimental 12 // UNSUPPORTED: c++98, c++03 13 14 // <experimental/unordered_set> 15 16 // namespace std { namespace experimental { namespace pmr { 17 // template <class V, class H = hash<V>, class P = equal_to<V> > 18 // using unordered_set = 19 // ::std::unordered_set<V, H, P, polymorphic_allocator<V>> 20 // 21 // template <class V, class H = hash<V>, class P = equal_to<V> > 22 // using unordered_multiset = 23 // ::std::unordered_multiset<V, H, P, polymorphic_allocator<V>> 24 // 25 // }}} // namespace std::experimental::pmr 26 27 #include <experimental/unordered_set> 28 #include <experimental/memory_resource> 29 #include <type_traits> 30 #include <cassert> 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 40 int main() 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