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 multimap 13 14 // multimap(initializer_list<value_type> il, const key_compare& comp = key_compare()); 15 16 #include <map> 17 #include <cassert> 18 #include "../../../test_compare.h" 19 #include "min_allocator.h" 20 21 int main() 22 { 23 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 24 { 25 typedef test_compare<std::less<int> > Cmp; 26 typedef std::multimap<int, double, Cmp> C; 27 typedef C::value_type V; 28 C m( 29 { 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 }, 40 Cmp(4) 41 ); 42 assert(m.size() == 9); 43 assert(distance(m.begin(), m.end()) == 9); 44 C::const_iterator i = m.cbegin(); 45 assert(*i == V(1, 1)); 46 assert(*++i == V(1, 1.5)); 47 assert(*++i == V(1, 2)); 48 assert(*++i == V(2, 1)); 49 assert(*++i == V(2, 1.5)); 50 assert(*++i == V(2, 2)); 51 assert(*++i == V(3, 1)); 52 assert(*++i == V(3, 1.5)); 53 assert(*++i == V(3, 2)); 54 assert(m.key_comp() == Cmp(4)); 55 } 56 #if __cplusplus >= 201103L 57 { 58 typedef test_compare<std::less<int> > Cmp; 59 typedef std::multimap<int, double, Cmp, min_allocator<std::pair<const int, double>>> C; 60 typedef C::value_type V; 61 C m( 62 { 63 {1, 1}, 64 {1, 1.5}, 65 {1, 2}, 66 {2, 1}, 67 {2, 1.5}, 68 {2, 2}, 69 {3, 1}, 70 {3, 1.5}, 71 {3, 2} 72 }, 73 Cmp(4) 74 ); 75 assert(m.size() == 9); 76 assert(distance(m.begin(), m.end()) == 9); 77 C::const_iterator i = m.cbegin(); 78 assert(*i == V(1, 1)); 79 assert(*++i == V(1, 1.5)); 80 assert(*++i == V(1, 2)); 81 assert(*++i == V(2, 1)); 82 assert(*++i == V(2, 1.5)); 83 assert(*++i == V(2, 2)); 84 assert(*++i == V(3, 1)); 85 assert(*++i == V(3, 1.5)); 86 assert(*++i == V(3, 2)); 87 assert(m.key_comp() == Cmp(4)); 88 } 89 #endif 90 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 91 } 92