[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / associative / map / map.cons / move.pass.cpp
blob0e68ba4a17fe6e26344cd35629d995b39e294f2b
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 // UNSUPPORTED: c++03
11 // <map>
13 // class map
15 // map(map&& m);
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**)
27 typedef std::pair<const int, double> V;
29 typedef test_less<int> C;
30 typedef test_allocator<V> A;
31 std::map<int, double, C, A> mo(C(5), A(7));
32 std::map<int, double, C, A> m = std::move(mo);
33 assert(m.get_allocator() == A(7));
34 assert(m.key_comp() == C(5));
35 assert(m.size() == 0);
36 assert(std::distance(m.begin(), m.end()) == 0);
38 assert(mo.get_allocator() == A(test_alloc_base::moved_value));
39 assert(mo.key_comp() == C(5));
40 assert(mo.size() == 0);
41 assert(std::distance(mo.begin(), mo.end()) == 0);
44 V ar[] =
46 V(1, 1),
47 V(1, 1.5),
48 V(1, 2),
49 V(2, 1),
50 V(2, 1.5),
51 V(2, 2),
52 V(3, 1),
53 V(3, 1.5),
54 V(3, 2),
56 typedef test_less<int> C;
57 typedef test_allocator<V> A;
58 std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
59 std::map<int, double, C, A> m = std::move(mo);
60 assert(m.get_allocator() == A(7));
61 assert(m.key_comp() == C(5));
62 assert(m.size() == 3);
63 assert(std::distance(m.begin(), m.end()) == 3);
64 assert(*m.begin() == V(1, 1));
65 assert(*std::next(m.begin()) == V(2, 1));
66 assert(*std::next(m.begin(), 2) == V(3, 1));
68 assert(mo.get_allocator() == A(test_alloc_base::moved_value));
69 assert(mo.key_comp() == C(5));
70 assert(mo.size() == 0);
71 assert(std::distance(mo.begin(), mo.end()) == 0);
74 typedef test_less<int> C;
75 typedef min_allocator<V> A;
76 std::map<int, double, C, A> mo(C(5), A());
77 std::map<int, double, C, A> m = std::move(mo);
78 assert(m.get_allocator() == A());
79 assert(m.key_comp() == C(5));
80 assert(m.size() == 0);
81 assert(std::distance(m.begin(), m.end()) == 0);
83 assert(mo.get_allocator() == A());
84 assert(mo.key_comp() == C(5));
85 assert(mo.size() == 0);
86 assert(std::distance(mo.begin(), mo.end()) == 0);
89 V ar[] =
91 V(1, 1),
92 V(1, 1.5),
93 V(1, 2),
94 V(2, 1),
95 V(2, 1.5),
96 V(2, 2),
97 V(3, 1),
98 V(3, 1.5),
99 V(3, 2),
101 typedef test_less<int> C;
102 typedef min_allocator<V> A;
103 std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
104 std::map<int, double, C, A> m = std::move(mo);
105 assert(m.get_allocator() == A());
106 assert(m.key_comp() == C(5));
107 assert(m.size() == 3);
108 assert(std::distance(m.begin(), m.end()) == 3);
109 assert(*m.begin() == V(1, 1));
110 assert(*std::next(m.begin()) == V(2, 1));
111 assert(*std::next(m.begin(), 2) == V(3, 1));
113 assert(mo.get_allocator() == A());
114 assert(mo.key_comp() == C(5));
115 assert(mo.size() == 0);
116 assert(std::distance(mo.begin(), mo.end()) == 0);
119 return 0;