[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / sequences / vector.bool / move.pass.cpp
blob0e65d9896f4020bf3534acbbeb6cf0fec60e8507
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 // <vector>
13 // vector(vector&& c);
15 #include <vector>
16 #include <cassert>
17 #include "test_macros.h"
18 #include "test_allocator.h"
19 #include "min_allocator.h"
21 TEST_CONSTEXPR_CXX20 bool tests()
23 test_allocator_statistics alloc_stats;
25 std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5, &alloc_stats));
26 std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5, &alloc_stats));
27 for (int i = 1; i <= 3; ++i)
29 l.push_back(true);
30 lo.push_back(true);
32 std::vector<bool, test_allocator<bool> > l2 = std::move(l);
33 assert(l2 == lo);
34 assert(l.empty());
35 assert(l2.get_allocator() == lo.get_allocator());
38 std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
39 std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
40 for (int i = 1; i <= 3; ++i)
42 l.push_back(true);
43 lo.push_back(true);
45 std::vector<bool, other_allocator<bool> > l2 = std::move(l);
46 assert(l2 == lo);
47 assert(l.empty());
48 assert(l2.get_allocator() == lo.get_allocator());
51 std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
52 std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
53 for (int i = 1; i <= 3; ++i)
55 l.push_back(true);
56 lo.push_back(true);
58 std::vector<bool, min_allocator<bool> > l2 = std::move(l);
59 assert(l2 == lo);
60 assert(l.empty());
61 assert(l2.get_allocator() == lo.get_allocator());
64 alloc_stats.clear();
65 using Vect = std::vector<bool, test_allocator<bool> >;
66 using AllocT = Vect::allocator_type;
67 Vect v(test_allocator<bool>(42, 101, &alloc_stats));
68 assert(alloc_stats.count == 1);
70 const AllocT& a = v.get_allocator();
71 assert(alloc_stats.count == 2);
72 assert(a.get_data() == 42);
73 assert(a.get_id() == 101);
75 assert(alloc_stats.count == 1);
76 alloc_stats.clear_ctor_counters();
78 Vect v2 = std::move(v);
79 assert(alloc_stats.count == 2);
80 assert(alloc_stats.copied == 0);
81 assert(alloc_stats.moved == 1);
83 const AllocT& a = v.get_allocator();
84 assert(a.get_id() == test_alloc_base::moved_value);
85 assert(a.get_data() == test_alloc_base::moved_value);
88 const AllocT& a = v2.get_allocator();
89 assert(a.get_id() == 101);
90 assert(a.get_data() == 42);
94 return true;
97 int main(int, char**)
99 tests();
100 #if TEST_STD_VER > 17
101 static_assert(tests());
102 #endif
103 return 0;