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// vector<bool>
11
12// static void swap(reference x, reference y) noexcept;
13
14#include <vector>
15#include <cassert>
16
17#include "test_macros.h"
18
19TEST_CONSTEXPR_CXX20 bool tests()
20{
21
22 bool a[] = {false, true, false, true};
23 bool* an = a + sizeof(a)/sizeof(a[0]);
24
25 std::vector<bool> v(a, an);
26 std::vector<bool>::reference r1 = v[0];
27 std::vector<bool>::reference r2 = v[3];
28
29#if TEST_STD_VER >= 11
30 static_assert((noexcept(v.swap(r1,r2))), "");
31#endif
32
33 assert(!r1);
34 assert( r2);
35 v.swap(r1, r2);
36 assert( r1);
37 assert(!r2);
38
39 return true;
40}
41
42int main(int, char**)
43{
44 tests();
45#if TEST_STD_VER > 17
46 static_assert(tests());
47#endif
48 return 0;
49}
50

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