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 // <map> 11 12 // class map 13 14 // map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); 15 16 #include <map> 17 #include <cassert> 18 #include "../../../test_compare.h" 19 #include "../../../test_allocator.h" 20 #include "../../../min_allocator.h" 21 22 int main() 23 { 24 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 25 { 26 typedef std::pair<const int, double> V; 27 typedef test_compare<std::less<int> > C; 28 typedef test_allocator<std::pair<const int, double> > A; 29 std::map<int, double, C, A> m({ 30 {1, 1}, 31 {1, 1.5}, 32 {1, 2}, 33 {2, 1}, 34 {2, 1.5}, 35 {2, 2}, 36 {3, 1}, 37 {3, 1.5}, 38 {3, 2} 39 }, C(3), A(6)); 40 assert(m.size() == 3); 41 assert(distance(m.begin(), m.end()) == 3); 42 assert(*m.begin() == V(1, 1)); 43 assert(*next(m.begin()) == V(2, 1)); 44 assert(*next(m.begin(), 2) == V(3, 1)); 45 assert(m.key_comp() == C(3)); 46 assert(m.get_allocator() == A(6)); 47 } 48 #if __cplusplus >= 201103L 49 { 50 typedef std::pair<const int, double> V; 51 typedef test_compare<std::less<int> > C; 52 typedef min_allocator<std::pair<const int, double> > A; 53 std::map<int, double, C, A> m({ 54 {1, 1}, 55 {1, 1.5}, 56 {1, 2}, 57 {2, 1}, 58 {2, 1.5}, 59 {2, 2}, 60 {3, 1}, 61 {3, 1.5}, 62 {3, 2} 63 }, C(3), A()); 64 assert(m.size() == 3); 65 assert(distance(m.begin(), m.end()) == 3); 66 assert(*m.begin() == V(1, 1)); 67 assert(*next(m.begin()) == V(2, 1)); 68 assert(*next(m.begin(), 2) == V(3, 1)); 69 assert(m.key_comp() == C(3)); 70 assert(m.get_allocator() == A()); 71 } 72 #endif 73 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 74 } 75