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 // void insert(initializer_list<value_type> il);
15
16 #include <map>
17 #include <cassert>
18
19 #include "min_allocator.h"
20
main()21 int main()
22 {
23 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
24 {
25 typedef std::pair<const int, double> V;
26 std::map<int, double> m =
27 {
28 {1, 1},
29 {1, 1.5},
30 {1, 2},
31 {3, 1},
32 {3, 1.5},
33 {3, 2}
34 };
35 m.insert({
36 {2, 1},
37 {2, 1.5},
38 {2, 2},
39 });
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 }
46 #if __cplusplus >= 201103L
47 {
48 typedef std::pair<const int, double> V;
49 std::map<int, double, std::less<int>, min_allocator<V>> m =
50 {
51 {1, 1},
52 {1, 1.5},
53 {1, 2},
54 {3, 1},
55 {3, 1.5},
56 {3, 2}
57 };
58 m.insert({
59 {2, 1},
60 {2, 1.5},
61 {2, 2},
62 });
63 assert(m.size() == 3);
64 assert(distance(m.begin(), m.end()) == 3);
65 assert(*m.begin() == V(1, 1));
66 assert(*next(m.begin()) == V(2, 1));
67 assert(*next(m.begin(), 2) == V(3, 1));
68 }
69 #endif
70 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
71 }
72