brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · a0476b6 Raw
47 lines · cpp
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-exception6//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  bool a[] = {false, true, false, true};21  bool* an = a + sizeof(a) / sizeof(a[0]);22 23  std::vector<bool> v(a, an);24  std::vector<bool>::reference r1 = v[0];25  std::vector<bool>::reference r2 = v[3];26 27#if TEST_STD_VER >= 1128  static_assert((noexcept(v.swap(r1, r2))), "");29#endif30 31  assert(!r1);32  assert(r2);33  v.swap(r1, r2);34  assert(r1);35  assert(!r2);36 37  return true;38}39 40int main(int, char**) {41  tests();42#if TEST_STD_VER > 1743  static_assert(tests());44#endif45  return 0;46}47