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 | typedef std::multimap<int, double> C; |
26 | typedef C::value_type V; |
27 | C m = {{1, 1}, {1, 2}, {2, 1}, {2, 2}, {3, 1}, {3, 2}}; |
28 | m.insert(l: { |
29 | {1, 1.5}, |
30 | {2, 1.5}, |
31 | {3, 1.5}, |
32 | }); |
33 | assert(m.size() == 9); |
34 | assert(std::distance(m.begin(), m.end()) == 9); |
35 | C::const_iterator i = m.cbegin(); |
36 | assert(*i == V(1, 1)); |
37 | assert(*++i == V(1, 2)); |
38 | assert(*++i == V(1, 1.5)); |
39 | assert(*++i == V(2, 1)); |
40 | assert(*++i == V(2, 2)); |
41 | assert(*++i == V(2, 1.5)); |
42 | assert(*++i == V(3, 1)); |
43 | assert(*++i == V(3, 2)); |
44 | assert(*++i == V(3, 1.5)); |
45 | } |
46 | { |
47 | typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C; |
48 | typedef C::value_type V; |
49 | C m = {{1, 1}, {1, 2}, {2, 1}, {2, 2}, {3, 1}, {3, 2}}; |
50 | m.insert({ |
51 | {1, 1.5}, |
52 | {2, 1.5}, |
53 | {3, 1.5}, |
54 | }); |
55 | assert(m.size() == 9); |
56 | assert(std::distance(m.begin(), m.end()) == 9); |
57 | C::const_iterator i = m.cbegin(); |
58 | assert(*i == V(1, 1)); |
59 | assert(*++i == V(1, 2)); |
60 | assert(*++i == V(1, 1.5)); |
61 | assert(*++i == V(2, 1)); |
62 | assert(*++i == V(2, 2)); |
63 | assert(*++i == V(2, 1.5)); |
64 | assert(*++i == V(3, 1)); |
65 | assert(*++i == V(3, 2)); |
66 | assert(*++i == V(3, 1.5)); |
67 | } |
68 | |
69 | return 0; |
70 | } |
71 | |