1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // vector(const vector& v, const allocator_type& a);
16 #include "test_macros.h"
17 #include "test_allocator.h"
18 #include "min_allocator.h"
21 TEST_CONSTEXPR_CXX20
void test(const C
& x
, const typename
C::allocator_type
& a
)
23 typename
C::size_type s
= x
.size();
25 LIBCPP_ASSERT(c
.__invariants());
26 assert(c
.size() == s
);
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));
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));
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>());
59 assert(l2
.get_allocator() == min_allocator
<bool>());
70 static_assert(tests());