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++98, c++03
13 // vector(vector&& c);
17 #include "test_macros.h"
18 #include "test_allocator.h"
19 #include "min_allocator.h"
24 std::vector
<bool, test_allocator
<bool> > l(test_allocator
<bool>(5));
25 std::vector
<bool, test_allocator
<bool> > lo(test_allocator
<bool>(5));
26 for (int i
= 1; i
<= 3; ++i
)
31 std::vector
<bool, test_allocator
<bool> > l2
= std::move(l
);
34 assert(l2
.get_allocator() == lo
.get_allocator());
37 std::vector
<bool, other_allocator
<bool> > l(other_allocator
<bool>(5));
38 std::vector
<bool, other_allocator
<bool> > lo(other_allocator
<bool>(5));
39 for (int i
= 1; i
<= 3; ++i
)
44 std::vector
<bool, other_allocator
<bool> > l2
= std::move(l
);
47 assert(l2
.get_allocator() == lo
.get_allocator());
50 std::vector
<bool, min_allocator
<bool> > l(min_allocator
<bool>{});
51 std::vector
<bool, min_allocator
<bool> > lo(min_allocator
<bool>{});
52 for (int i
= 1; i
<= 3; ++i
)
57 std::vector
<bool, min_allocator
<bool> > l2
= std::move(l
);
60 assert(l2
.get_allocator() == lo
.get_allocator());
63 test_alloc_base::clear();
64 using Vect
= std::vector
<bool, test_allocator
<bool> >;
65 using AllocT
= Vect::allocator_type
;
66 Vect
v(test_allocator
<bool>(42, 101));
67 assert(test_alloc_base::count
== 1);
69 const AllocT
& a
= v
.get_allocator();
70 assert(test_alloc_base::count
== 2);
71 assert(a
.get_data() == 42);
72 assert(a
.get_id() == 101);
74 assert(test_alloc_base::count
== 1);
75 test_alloc_base::clear_ctor_counters();
77 Vect v2
= std::move(v
);
78 assert(test_alloc_base::count
== 2);
79 assert(test_alloc_base::copied
== 0);
80 assert(test_alloc_base::moved
== 1);
82 const AllocT
& a
= v
.get_allocator();
83 assert(a
.get_id() == test_alloc_base::moved_value
);
84 assert(a
.get_data() == test_alloc_base::moved_value
);
87 const AllocT
& a
= v2
.get_allocator();
88 assert(a
.get_id() == 101);
89 assert(a
.get_data() == 42);