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 19 #include "min_allocator.h" 20 21 int main() 22 { 23 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 24 { 25 typedef std::multimap<int, double> C; 26 typedef C::value_type V; 27 C m = 28 { 29 {1, 1}, 30 {1, 1.5}, 31 {1, 2}, 32 {2, 1}, 33 {2, 1.5}, 34 {2, 2}, 35 {3, 1}, 36 {3, 1.5}, 37 {3, 2} 38 }; 39 assert(m.size() == 9); 40 assert(distance(m.begin(), m.end()) == 9); 41 C::const_iterator i = m.cbegin(); 42 assert(*i == V(1, 1)); 43 assert(*++i == V(1, 1.5)); 44 assert(*++i == V(1, 2)); 45 assert(*++i == V(2, 1)); 46 assert(*++i == V(2, 1.5)); 47 assert(*++i == V(2, 2)); 48 assert(*++i == V(3, 1)); 49 assert(*++i == V(3, 1.5)); 50 assert(*++i == V(3, 2)); 51 } 52 #if __cplusplus >= 201103L 53 { 54 typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C; 55 typedef C::value_type V; 56 C m = 57 { 58 {1, 1}, 59 {1, 1.5}, 60 {1, 2}, 61 {2, 1}, 62 {2, 1.5}, 63 {2, 2}, 64 {3, 1}, 65 {3, 1.5}, 66 {3, 2} 67 }; 68 assert(m.size() == 9); 69 assert(distance(m.begin(), m.end()) == 9); 70 C::const_iterator i = m.cbegin(); 71 assert(*i == V(1, 1)); 72 assert(*++i == V(1, 1.5)); 73 assert(*++i == V(1, 2)); 74 assert(*++i == V(2, 1)); 75 assert(*++i == V(2, 1.5)); 76 assert(*++i == V(2, 2)); 77 assert(*++i == V(3, 1)); 78 assert(*++i == V(3, 1.5)); 79 assert(*++i == V(3, 2)); 80 } 81 #endif 82 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 83 } 84