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 multimap |
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 | |
23 | int main(int, char**) |
24 | { |
25 | { |
26 | typedef std::multimap<int, double> C; |
27 | typedef C::value_type V; |
28 | C m = |
29 | { |
30 | {1, 1}, |
31 | {1, 2}, |
32 | {2, 1}, |
33 | {2, 2}, |
34 | {3, 1}, |
35 | {3, 2} |
36 | }; |
37 | m.insert( |
38 | l: { |
39 | {1, 1.5}, |
40 | {2, 1.5}, |
41 | {3, 1.5}, |
42 | } |
43 | ); |
44 | assert(m.size() == 9); |
45 | assert(std::distance(m.begin(), m.end()) == 9); |
46 | C::const_iterator i = m.cbegin(); |
47 | assert(*i == V(1, 1)); |
48 | assert(*++i == V(1, 2)); |
49 | assert(*++i == V(1, 1.5)); |
50 | assert(*++i == V(2, 1)); |
51 | assert(*++i == V(2, 2)); |
52 | assert(*++i == V(2, 1.5)); |
53 | assert(*++i == V(3, 1)); |
54 | assert(*++i == V(3, 2)); |
55 | assert(*++i == V(3, 1.5)); |
56 | } |
57 | { |
58 | typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C; |
59 | typedef C::value_type V; |
60 | C m = |
61 | { |
62 | {1, 1}, |
63 | {1, 2}, |
64 | {2, 1}, |
65 | {2, 2}, |
66 | {3, 1}, |
67 | {3, 2} |
68 | }; |
69 | m.insert( |
70 | { |
71 | {1, 1.5}, |
72 | {2, 1.5}, |
73 | {3, 1.5}, |
74 | } |
75 | ); |
76 | assert(m.size() == 9); |
77 | assert(std::distance(m.begin(), m.end()) == 9); |
78 | C::const_iterator i = m.cbegin(); |
79 | assert(*i == V(1, 1)); |
80 | assert(*++i == V(1, 2)); |
81 | assert(*++i == V(1, 1.5)); |
82 | assert(*++i == V(2, 1)); |
83 | assert(*++i == V(2, 2)); |
84 | assert(*++i == V(2, 1.5)); |
85 | assert(*++i == V(3, 1)); |
86 | assert(*++i == V(3, 2)); |
87 | assert(*++i == V(3, 1.5)); |
88 | } |
89 | |
90 | return 0; |
91 | } |
92 | |