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