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//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03
10
11// <vector>
12
13// vector& operator=(vector&& c);
14
15#include <vector>
16#include <cassert>
17#include "test_macros.h"
18#include "test_allocator.h"
19#include "min_allocator.h"
20
21TEST_CONSTEXPR_CXX20 bool tests()
22{
23 {
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)
27 {
28 l.push_back(i);
29 lo.push_back(i);
30 }
31 std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(5));
32 l2 = std::move(l);
33 assert(l2 == lo);
34 LIBCPP_ASSERT(l.empty());
35 assert(l2.get_allocator() == lo.get_allocator());
36 }
37 {
38 std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
39 std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
40 for (int i = 1; i <= 3; ++i)
41 {
42 l.push_back(i);
43 lo.push_back(i);
44 }
45 std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(6));
46 l2 = std::move(l);
47 assert(l2 == lo);
48 assert(!l.empty());
49 assert(l2.get_allocator() == test_allocator<bool>(6));
50 }
51 {
52 std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
53 std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
54 for (int i = 1; i <= 3; ++i)
55 {
56 l.push_back(i);
57 lo.push_back(i);
58 }
59 std::vector<bool, other_allocator<bool> > l2(other_allocator<bool>(6));
60 l2 = std::move(l);
61 assert(l2 == lo);
62 assert(l.empty());
63 assert(l2.get_allocator() == lo.get_allocator());
64 }
65 {
66 std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
67 std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
68 for (int i = 1; i <= 3; ++i)
69 {
70 l.push_back(i);
71 lo.push_back(i);
72 }
73 std::vector<bool, min_allocator<bool> > l2(min_allocator<bool>{});
74 l2 = std::move(l);
75 assert(l2 == lo);
76 assert(l.empty());
77 assert(l2.get_allocator() == lo.get_allocator());
78 }
79
80 return true;
81}
82
83int main(int, char**)
84{
85 tests();
86#if TEST_STD_VER > 17
87 static_assert(tests());
88#endif
89 return 0;
90}
91

source code of libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp