1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include <map> 11 #include <set> 12 #include <type_traits> 13 14 #include "test_macros.h" 15 #include "min_allocator.h" 16 #include "test_allocator.h" 17 18 19 template <class Map, class ValueTp, class PtrT, class CPtrT> 20 void testMap() { 21 typedef typename Map::difference_type Diff; 22 { 23 typedef typename Map::iterator It; 24 static_assert((std::is_same<typename It::value_type, ValueTp>::value), ""); 25 static_assert((std::is_same<typename It::reference, ValueTp&>::value), ""); 26 static_assert((std::is_same<typename It::pointer, PtrT>::value), ""); 27 static_assert((std::is_same<typename It::difference_type, Diff>::value), ""); 28 } 29 { 30 typedef typename Map::const_iterator It; 31 static_assert((std::is_same<typename It::value_type, ValueTp>::value), ""); 32 static_assert((std::is_same<typename It::reference, ValueTp const&>::value), ""); 33 static_assert((std::is_same<typename It::pointer, CPtrT>::value), ""); 34 static_assert((std::is_same<typename It::difference_type, Diff>::value), ""); 35 } 36 } 37 38 39 template <class Set, class ValueTp, class CPtrT> 40 void testSet() { 41 static_assert((std::is_same<typename Set::iterator, 42 typename Set::const_iterator>::value), ""); 43 typedef typename Set::difference_type Diff; 44 { 45 typedef typename Set::iterator It; 46 static_assert((std::is_same<typename It::value_type, ValueTp>::value), ""); 47 static_assert((std::is_same<typename It::reference, ValueTp const&>::value), ""); 48 static_assert((std::is_same<typename It::pointer, CPtrT>::value), ""); 49 static_assert((std::is_same<typename It::difference_type, Diff>::value), ""); 50 51 } 52 } 53 54 int main() { 55 { 56 typedef std::map<int, int> Map; 57 typedef std::pair<const int, int> ValueTp; 58 testMap<Map, ValueTp, ValueTp*, ValueTp const*>(); 59 } 60 { 61 typedef std::pair<const int, int> ValueTp; 62 typedef test_allocator<ValueTp> Alloc; 63 typedef std::map<int, int, std::less<int>, Alloc> Map; 64 testMap<Map, ValueTp, ValueTp*, ValueTp const*>(); 65 } 66 #if TEST_STD_VER >= 11 67 { 68 typedef std::pair<const int, int> ValueTp; 69 typedef min_allocator<ValueTp> Alloc; 70 typedef std::map<int, int, std::less<int>, Alloc> Map; 71 testMap<Map, ValueTp, min_pointer<ValueTp>, min_pointer<const ValueTp>>(); 72 } 73 #endif 74 { 75 typedef std::multimap<int, int> Map; 76 typedef std::pair<const int, int> ValueTp; 77 testMap<Map, ValueTp, ValueTp*, ValueTp const*>(); 78 } 79 { 80 typedef std::pair<const int, int> ValueTp; 81 typedef test_allocator<ValueTp> Alloc; 82 typedef std::multimap<int, int, std::less<int>, Alloc> Map; 83 testMap<Map, ValueTp, ValueTp*, ValueTp const*>(); 84 } 85 #if TEST_STD_VER >= 11 86 { 87 typedef std::pair<const int, int> ValueTp; 88 typedef min_allocator<ValueTp> Alloc; 89 typedef std::multimap<int, int, std::less<int>, Alloc> Map; 90 testMap<Map, ValueTp, min_pointer<ValueTp>, min_pointer<const ValueTp>>(); 91 } 92 #endif 93 { 94 typedef int ValueTp; 95 typedef std::set<ValueTp> Set; 96 testSet<Set, ValueTp, ValueTp const*>(); 97 } 98 { 99 typedef int ValueTp; 100 typedef test_allocator<ValueTp> Alloc; 101 typedef std::set<ValueTp, std::less<ValueTp>, Alloc> Set; 102 testSet<Set, ValueTp, ValueTp const*>(); 103 } 104 #if TEST_STD_VER >= 11 105 { 106 typedef int ValueTp; 107 typedef min_allocator<ValueTp> Alloc; 108 typedef std::set<ValueTp, std::less<ValueTp>, Alloc> Set; 109 testSet<Set, ValueTp, min_pointer<const ValueTp>>(); 110 } 111 #endif 112 { 113 typedef int ValueTp; 114 typedef std::multiset<ValueTp> Set; 115 testSet<Set, ValueTp, ValueTp const*>(); 116 } 117 { 118 typedef int ValueTp; 119 typedef test_allocator<ValueTp> Alloc; 120 typedef std::multiset<ValueTp, std::less<ValueTp>, Alloc> Set; 121 testSet<Set, ValueTp, ValueTp const*>(); 122 } 123 #if TEST_STD_VER >= 11 124 { 125 typedef int ValueTp; 126 typedef min_allocator<ValueTp> Alloc; 127 typedef std::multiset<ValueTp, std::less<ValueTp>, Alloc> Set; 128 testSet<Set, ValueTp, min_pointer<const ValueTp>>(); 129 } 130 #endif 131 } 132