| 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 | // flip() |
| 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 | vec.push_back(false); |
| 23 | Ref ref = vec[0]; |
| 24 | assert(vec[0]); |
| 25 | assert(!vec[1]); |
| 26 | ref.flip(); |
| 27 | assert(!vec[0]); |
| 28 | assert(!vec[1]); |
| 29 | ref.flip(); |
| 30 | assert(vec[0]); |
| 31 | assert(!vec[1]); |
| 32 | |
| 33 | return true; |
| 34 | } |
| 35 | |
| 36 | int main(int, char**) { |
| 37 | test(); |
| 38 | #if TEST_STD_VER > 17 |
| 39 | static_assert(test()); |
| 40 | #endif |
| 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | |