[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / sequences / vector.bool / copy_alloc.pass.cpp
blob468bf5d866004ef72e5aeef48b8f524711a4a71d
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 // <vector>
11 // vector(const vector& v, const allocator_type& a);
13 #include <vector>
14 #include <cassert>
16 #include "test_macros.h"
17 #include "test_allocator.h"
18 #include "min_allocator.h"
20 template <class C>
21 TEST_CONSTEXPR_CXX20 void test(const C& x, const typename C::allocator_type& a)
23 typename C::size_type s = x.size();
24 C c(x, a);
25 LIBCPP_ASSERT(c.__invariants());
26 assert(c.size() == s);
27 assert(c == x);
30 TEST_CONSTEXPR_CXX20 bool tests()
33 bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
34 bool* an = a + sizeof(a)/sizeof(a[0]);
35 test(std::vector<bool>(a, an), std::allocator<bool>());
38 std::vector<bool, test_allocator<bool> > l(3, true, test_allocator<bool>(5));
39 std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
40 assert(l2 == l);
41 assert(l2.get_allocator() == test_allocator<bool>(3));
44 std::vector<bool, other_allocator<bool> > l(3, true, other_allocator<bool>(5));
45 std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
46 assert(l2 == l);
47 assert(l2.get_allocator() == other_allocator<bool>(3));
49 #if TEST_STD_VER >= 11
51 bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
52 bool* an = a + sizeof(a)/sizeof(a[0]);
53 test(std::vector<bool, min_allocator<bool>>(a, an), min_allocator<bool>());
56 std::vector<bool, min_allocator<bool> > l(3, true, min_allocator<bool>());
57 std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
58 assert(l2 == l);
59 assert(l2.get_allocator() == min_allocator<bool>());
61 #endif
63 return true;
66 int main(int, char**)
68 tests();
69 #if TEST_STD_VER > 17
70 static_assert(tests());
71 #endif
72 return 0;