[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / associative / multimap / multimap.cons / iter_iter_comp_alloc.pass.cpp
blob0d0f0b57ed485562f2baf9e6b065a84a61a3c389
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 //===----------------------------------------------------------------------===//
9 // <map>
11 // class multimap
13 // template <class InputIterator>
14 // multimap(InputIterator first, InputIterator last,
15 // const key_compare& comp, const allocator_type& a);
17 #include <map>
18 #include <cassert>
20 #include "test_macros.h"
21 #include "../../../test_compare.h"
22 #include "test_allocator.h"
23 #include "min_allocator.h"
25 int main(int, char**)
28 typedef std::pair<const int, double> V;
29 V ar[] =
31 V(1, 1),
32 V(1, 1.5),
33 V(1, 2),
34 V(2, 1),
35 V(2, 1.5),
36 V(2, 2),
37 V(3, 1),
38 V(3, 1.5),
39 V(3, 2),
41 typedef test_less<int> C;
42 typedef test_allocator<V> A;
43 std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
44 assert(m.get_allocator() == A(7));
45 assert(m.key_comp() == C(5));
46 assert(m.size() == 9);
47 assert(std::distance(m.begin(), m.end()) == 9);
48 assert(*m.begin() == V(1, 1));
49 assert(*std::next(m.begin()) == V(1, 1.5));
50 assert(*std::next(m.begin(), 2) == V(1, 2));
51 assert(*std::next(m.begin(), 3) == V(2, 1));
52 assert(*std::next(m.begin(), 4) == V(2, 1.5));
53 assert(*std::next(m.begin(), 5) == V(2, 2));
54 assert(*std::next(m.begin(), 6) == V(3, 1));
55 assert(*std::next(m.begin(), 7) == V(3, 1.5));
56 assert(*std::next(m.begin(), 8) == V(3, 2));
58 #if TEST_STD_VER >= 11
60 typedef std::pair<const int, double> V;
61 V ar[] =
63 V(1, 1),
64 V(1, 1.5),
65 V(1, 2),
66 V(2, 1),
67 V(2, 1.5),
68 V(2, 2),
69 V(3, 1),
70 V(3, 1.5),
71 V(3, 2),
73 typedef test_less<int> C;
74 typedef min_allocator<V> A;
75 std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
76 assert(m.get_allocator() == A());
77 assert(m.key_comp() == C(5));
78 assert(m.size() == 9);
79 assert(std::distance(m.begin(), m.end()) == 9);
80 assert(*m.begin() == V(1, 1));
81 assert(*std::next(m.begin()) == V(1, 1.5));
82 assert(*std::next(m.begin(), 2) == V(1, 2));
83 assert(*std::next(m.begin(), 3) == V(2, 1));
84 assert(*std::next(m.begin(), 4) == V(2, 1.5));
85 assert(*std::next(m.begin(), 5) == V(2, 2));
86 assert(*std::next(m.begin(), 6) == V(3, 1));
87 assert(*std::next(m.begin(), 7) == V(3, 1.5));
88 assert(*std::next(m.begin(), 8) == V(3, 2));
91 typedef std::pair<const int, double> V;
92 V ar[] =
94 V(1, 1),
95 V(1, 1.5),
96 V(1, 2),
97 V(2, 1),
98 V(2, 1.5),
99 V(2, 2),
100 V(3, 1),
101 V(3, 1.5),
102 V(3, 2),
104 typedef test_less<int> C;
105 typedef explicit_allocator<V> A;
106 std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A{});
107 assert(m.get_allocator() == A{});
108 assert(m.key_comp() == C(5));
109 assert(m.size() == 9);
110 assert(std::distance(m.begin(), m.end()) == 9);
111 assert(*m.begin() == V(1, 1));
112 assert(*std::next(m.begin()) == V(1, 1.5));
113 assert(*std::next(m.begin(), 2) == V(1, 2));
114 assert(*std::next(m.begin(), 3) == V(2, 1));
115 assert(*std::next(m.begin(), 4) == V(2, 1.5));
116 assert(*std::next(m.begin(), 5) == V(2, 2));
117 assert(*std::next(m.begin(), 6) == V(3, 1));
118 assert(*std::next(m.begin(), 7) == V(3, 1.5));
119 assert(*std::next(m.begin(), 8) == V(3, 2));
121 #endif
123 return 0;