Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / containers / sequences / vector.bool / move_alloc.pass.cpp
blob1f41657eb56eac9ac1303e11217593060a6c6ba0
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 // UNSUPPORTED: c++03
11 // <vector>
13 // vector(vector&& c, const allocator_type& a);
15 #include <vector>
16 #include <cassert>
17 #include "test_macros.h"
18 #include "test_allocator.h"
19 #include "min_allocator.h"
21 TEST_CONSTEXPR_CXX20 bool tests()
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)
28 l.push_back(i);
29 lo.push_back(i);
31 std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(6));
32 assert(l2 == lo);
33 assert(!l.empty());
34 assert(l2.get_allocator() == test_allocator<bool>(6));
37 std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
38 std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
39 for (int i = 1; i <= 3; ++i)
41 l.push_back(i);
42 lo.push_back(i);
44 std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(5));
45 assert(l2 == lo);
46 assert(l.empty());
47 assert(l2.get_allocator() == test_allocator<bool>(5));
50 std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
51 std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
52 for (int i = 1; i <= 3; ++i)
54 l.push_back(i);
55 lo.push_back(i);
57 std::vector<bool, other_allocator<bool> > l2(std::move(l), other_allocator<bool>(4));
58 assert(l2 == lo);
59 assert(!l.empty());
60 assert(l2.get_allocator() == other_allocator<bool>(4));
63 std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
64 std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
65 for (int i = 1; i <= 3; ++i)
67 l.push_back(i);
68 lo.push_back(i);
70 std::vector<bool, min_allocator<bool> > l2(std::move(l), min_allocator<bool>());
71 assert(l2 == lo);
72 assert(l.empty());
73 assert(l2.get_allocator() == min_allocator<bool>());
76 return true;
79 int main(int, char**)
81 tests();
82 #if TEST_STD_VER > 17
83 static_assert(tests());
84 #endif
85 return 0;