Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / containers / sequences / vector.bool / reference / assign_copy.pass.cpp
blob7568eb2f3cc3e96cec2dbc6910483815afd7dd48
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 // <vector>
11 // reference& operator=(const reference&)
13 #include <cassert>
14 #include <vector>
15 #include <utility>
17 #include "test_macros.h"
19 TEST_CONSTEXPR_CXX20 bool test() {
20 std::vector<bool> vec;
21 typedef std::vector<bool>::reference Ref;
22 vec.push_back(true);
23 vec.push_back(false);
24 Ref ref1 = vec[0];
25 Ref ref2 = vec[1];
26 ref2 = ref1;
27 // Ref&
29 vec[0] = false;
30 vec[1] = true;
31 ref1 = ref2;
32 assert(vec[0]);
33 assert(vec[1]);
36 vec[0] = true;
37 vec[1] = false;
38 ref1 = ref2;
39 assert(!vec[0]);
40 assert(!vec[1]);
42 // Ref&&
44 vec[0] = false;
45 vec[1] = true;
46 ref1 = std::move(ref2);
47 assert(vec[0]);
48 assert(vec[1]);
51 vec[0] = true;
52 vec[1] = false;
53 ref1 = std::move(ref2);
54 assert(!vec[0]);
55 assert(!vec[1]);
57 // const Ref&
59 vec[0] = false;
60 vec[1] = true;
61 ref1 = static_cast<const Ref&>(ref2);
62 assert(vec[0]);
63 assert(vec[1]);
66 vec[0] = true;
67 vec[1] = false;
68 ref1 = static_cast<const Ref&>(ref2);
69 assert(!vec[0]);
70 assert(!vec[1]);
72 return true;
75 int main(int, char**) {
76 test();
77 #if TEST_STD_VER > 17
78 static_assert(test());
79 #endif
81 return 0;