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 // UNSUPPORTED: c++98, c++03 11 12 // <map> 13 14 // class map 15 16 // map(initializer_list<value_type> il); 17 18 #include <map> 19 #include <cassert> 20 21 #include "min_allocator.h" 22 23 int main() 24 { 25 { 26 typedef std::pair<const int, double> V; 27 std::map<int, double> 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() == 3); 40 assert(distance(m.begin(), m.end()) == 3); 41 assert(*m.begin() == V(1, 1)); 42 assert(*next(m.begin()) == V(2, 1)); 43 assert(*next(m.begin(), 2) == V(3, 1)); 44 } 45 { 46 typedef std::pair<const int, double> V; 47 std::map<int, double, std::less<int>, min_allocator<V>> m = 48 { 49 {1, 1}, 50 {1, 1.5}, 51 {1, 2}, 52 {2, 1}, 53 {2, 1.5}, 54 {2, 2}, 55 {3, 1}, 56 {3, 1.5}, 57 {3, 2} 58 }; 59 assert(m.size() == 3); 60 assert(distance(m.begin(), m.end()) == 3); 61 assert(*m.begin() == V(1, 1)); 62 assert(*next(m.begin()) == V(2, 1)); 63 assert(*next(m.begin(), 2) == V(3, 1)); 64 } 65 } 66