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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03 && !stdlib=libc++
13 // vector(vector&& c, const allocator_type& a);
17 #include "test_macros.h"
19 #include "test_allocator.h"
20 #include "min_allocator.h"
21 #include "asan_testing.h"
23 TEST_CONSTEXPR_CXX20
bool tests()
26 std::vector
<MoveOnly
, test_allocator
<MoveOnly
> > l(test_allocator
<MoveOnly
>(5));
27 std::vector
<MoveOnly
, test_allocator
<MoveOnly
> > lo(test_allocator
<MoveOnly
>(5));
28 assert(is_contiguous_container_asan_correct(l
));
29 assert(is_contiguous_container_asan_correct(lo
));
30 for (int i
= 1; i
<= 3; ++i
)
35 assert(is_contiguous_container_asan_correct(l
));
36 assert(is_contiguous_container_asan_correct(lo
));
37 std::vector
<MoveOnly
, test_allocator
<MoveOnly
> > l2(std::move(l
), test_allocator
<MoveOnly
>(6));
40 assert(l2
.get_allocator() == test_allocator
<MoveOnly
>(6));
41 assert(is_contiguous_container_asan_correct(l2
));
44 std::vector
<MoveOnly
, test_allocator
<MoveOnly
> > l(test_allocator
<MoveOnly
>(5));
45 std::vector
<MoveOnly
, test_allocator
<MoveOnly
> > lo(test_allocator
<MoveOnly
>(5));
46 assert(is_contiguous_container_asan_correct(l
));
47 assert(is_contiguous_container_asan_correct(lo
));
48 for (int i
= 1; i
<= 3; ++i
)
53 assert(is_contiguous_container_asan_correct(l
));
54 assert(is_contiguous_container_asan_correct(lo
));
55 std::vector
<MoveOnly
, test_allocator
<MoveOnly
> > l2(std::move(l
), test_allocator
<MoveOnly
>(5));
58 assert(l2
.get_allocator() == test_allocator
<MoveOnly
>(5));
59 assert(is_contiguous_container_asan_correct(l2
));
62 std::vector
<MoveOnly
, other_allocator
<MoveOnly
> > l(other_allocator
<MoveOnly
>(5));
63 std::vector
<MoveOnly
, other_allocator
<MoveOnly
> > lo(other_allocator
<MoveOnly
>(5));
64 assert(is_contiguous_container_asan_correct(l
));
65 assert(is_contiguous_container_asan_correct(lo
));
66 for (int i
= 1; i
<= 3; ++i
)
71 assert(is_contiguous_container_asan_correct(l
));
72 assert(is_contiguous_container_asan_correct(lo
));
73 std::vector
<MoveOnly
, other_allocator
<MoveOnly
> > l2(std::move(l
), other_allocator
<MoveOnly
>(4));
76 assert(l2
.get_allocator() == other_allocator
<MoveOnly
>(4));
77 assert(is_contiguous_container_asan_correct(l2
));
80 std::vector
<MoveOnly
, min_allocator
<MoveOnly
> > l((min_allocator
<MoveOnly
>()));
81 std::vector
<MoveOnly
, min_allocator
<MoveOnly
> > lo((min_allocator
<MoveOnly
>()));
82 assert(is_contiguous_container_asan_correct(l
));
83 assert(is_contiguous_container_asan_correct(lo
));
84 for (int i
= 1; i
<= 3; ++i
)
89 assert(is_contiguous_container_asan_correct(l
));
90 assert(is_contiguous_container_asan_correct(lo
));
91 std::vector
<MoveOnly
, min_allocator
<MoveOnly
> > l2(std::move(l
), min_allocator
<MoveOnly
>());
94 assert(l2
.get_allocator() == min_allocator
<MoveOnly
>());
95 assert(is_contiguous_container_asan_correct(l2
));
98 std::vector
<MoveOnly
, safe_allocator
<MoveOnly
> > l((safe_allocator
<MoveOnly
>()));
99 std::vector
<MoveOnly
, safe_allocator
<MoveOnly
> > lo((safe_allocator
<MoveOnly
>()));
100 assert(is_contiguous_container_asan_correct(l
));
101 assert(is_contiguous_container_asan_correct(lo
));
102 for (int i
= 1; i
<= 3; ++i
) {
106 assert(is_contiguous_container_asan_correct(l
));
107 assert(is_contiguous_container_asan_correct(lo
));
108 std::vector
<MoveOnly
, safe_allocator
<MoveOnly
> > l2(std::move(l
), safe_allocator
<MoveOnly
>());
111 assert(l2
.get_allocator() == safe_allocator
<MoveOnly
>());
112 assert(is_contiguous_container_asan_correct(l2
));
118 int main(int, char**)
121 #if TEST_STD_VER > 17
122 static_assert(tests());