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 | // <vector> |
10 | |
11 | // reference(const reference&) |
12 | |
13 | #include <cassert> |
14 | #include <vector> |
15 | |
16 | #include "test_macros.h" |
17 | |
18 | TEST_CONSTEXPR_CXX20 bool test() { |
19 | std::vector<bool> vec; |
20 | typedef std::vector<bool>::reference Ref; |
21 | vec.push_back(true); |
22 | Ref ref = vec[0]; |
23 | Ref ref2 = ref; |
24 | assert(ref == ref2 && ref2); |
25 | ref.flip(); |
26 | assert(ref == ref2 && !ref2); |
27 | |
28 | return true; |
29 | } |
30 | |
31 | int main(int, char**) { |
32 | test(); |
33 | #if TEST_STD_VER > 17 |
34 | static_assert(test()); |
35 | #endif |
36 | |
37 | return 0; |
38 | } |
39 | |