[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / associative / map / map.cons / iter_iter_comp_alloc.pass.cpp
blobe8714346951da4d1c61fc2cc54069ceebbf48d8c
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 map
13 // template <class InputIterator>
14 // map(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::map<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() == 3);
47 assert(std::distance(m.begin(), m.end()) == 3);
48 assert(*m.begin() == V(1, 1));
49 assert(*std::next(m.begin()) == V(2, 1));
50 assert(*std::next(m.begin(), 2) == V(3, 1));
52 #if TEST_STD_VER >= 11
54 typedef std::pair<const int, double> V;
55 V ar[] =
57 V(1, 1),
58 V(1, 1.5),
59 V(1, 2),
60 V(2, 1),
61 V(2, 1.5),
62 V(2, 2),
63 V(3, 1),
64 V(3, 1.5),
65 V(3, 2),
67 typedef test_less<int> C;
68 typedef min_allocator<V> A;
69 std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
70 assert(m.get_allocator() == A());
71 assert(m.key_comp() == C(5));
72 assert(m.size() == 3);
73 assert(std::distance(m.begin(), m.end()) == 3);
74 assert(*m.begin() == V(1, 1));
75 assert(*std::next(m.begin()) == V(2, 1));
76 assert(*std::next(m.begin(), 2) == V(3, 1));
78 #if TEST_STD_VER > 11
80 typedef std::pair<const int, double> V;
81 V ar[] =
83 V(1, 1),
84 V(1, 1.5),
85 V(1, 2),
86 V(2, 1),
87 V(2, 1.5),
88 V(2, 2),
89 V(3, 1),
90 V(3, 1.5),
91 V(3, 2),
94 typedef min_allocator<V> A;
95 typedef test_less<int> C;
96 A a;
97 std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a );
99 assert(m.size() == 3);
100 assert(std::distance(m.begin(), m.end()) == 3);
101 assert(*m.begin() == V(1, 1));
102 assert(*std::next(m.begin()) == V(2, 1));
103 assert(*std::next(m.begin(), 2) == V(3, 1));
104 assert(m.get_allocator() == a);
107 typedef explicit_allocator<V> A;
108 typedef test_less<int> C;
109 A a;
110 std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a );
112 assert(m.size() == 3);
113 assert(std::distance(m.begin(), m.end()) == 3);
114 assert(*m.begin() == V(1, 1));
115 assert(*std::next(m.begin()) == V(2, 1));
116 assert(*std::next(m.begin(), 2) == V(3, 1));
117 assert(m.get_allocator() == a);
120 #endif
121 #endif
123 return 0;