1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // UNSUPPORTED: c++03
10
11 // <map>
12
13 // class map
14
15 // void insert(initializer_list<value_type> il);
16
17 #include <map>
18 #include <cassert>
19
20 #include "test_macros.h"
21 #include "min_allocator.h"
22
main(int,char **)23 int main(int, char**)
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 {3, 1},
33 {3, 1.5},
34 {3, 2}
35 };
36 m.insert({
37 {2, 1},
38 {2, 1.5},
39 {2, 2},
40 });
41 assert(m.size() == 3);
42 assert(std::distance(m.begin(), m.end()) == 3);
43 assert(*m.begin() == V(1, 1));
44 assert(*std::next(m.begin()) == V(2, 1));
45 assert(*std::next(m.begin(), 2) == V(3, 1));
46 }
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(std::distance(m.begin(), m.end()) == 3);
65 assert(*m.begin() == V(1, 1));
66 assert(*std::next(m.begin()) == V(2, 1));
67 assert(*std::next(m.begin(), 2) == V(3, 1));
68 }
69
70 return 0;
71 }
72