brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 5540136 Raw
55 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// bitset<N>& flip(); // constexpr since C++2310 11#include <bitset>12#include <cassert>13#include <cstddef>14#include <vector>15 16#include "../bitset_test_cases.h"17#include "test_macros.h"18 19template <std::size_t N>20TEST_CONSTEXPR_CXX23 void test_flip_all() {21  std::vector<std::bitset<N> > const cases = get_test_cases<N>();22  for (std::size_t c = 0; c != cases.size(); ++c) {23    std::bitset<N> v1 = cases[c];24    std::bitset<N> v2 = v1;25    v2.flip();26    for (std::size_t i = 0; i < v1.size(); ++i)27      assert(v2[i] == ~v1[i]);28  }29}30 31TEST_CONSTEXPR_CXX23 bool test() {32  test_flip_all<0>();33  test_flip_all<1>();34  test_flip_all<2>();35  test_flip_all<5>();36  test_flip_all<31>();37  test_flip_all<32>();38  test_flip_all<33>();39  test_flip_all<63>();40  test_flip_all<64>();41  test_flip_all<65>();42 43  return true;44}45 46int main(int, char**) {47  test();48  test_flip_all<1000>(); // not in constexpr because of constexpr evaluation step limits49#if TEST_STD_VER > 2050  static_assert(test());51#endif52 53  return 0;54}55