| 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 | // bitset<N> operator~() const; // constexpr since C++23 |
| 10 | |
| 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 | |
| 19 | template <std::size_t N> |
| 20 | TEST_CONSTEXPR_CXX23 void test_not_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 | for (std::size_t i = 0; i < v1.size(); ++i) |
| 26 | assert(v2[i] == ~v1[i]); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | TEST_CONSTEXPR_CXX23 bool test() { |
| 31 | test_not_all<0>(); |
| 32 | test_not_all<1>(); |
| 33 | test_not_all<31>(); |
| 34 | test_not_all<32>(); |
| 35 | test_not_all<33>(); |
| 36 | test_not_all<63>(); |
| 37 | test_not_all<64>(); |
| 38 | test_not_all<65>(); |
| 39 | |
| 40 | return true; |
| 41 | } |
| 42 | |
| 43 | int main(int, char**) { |
| 44 | test(); |
| 45 | test_not_all<1000>(); // not in constexpr because of constexpr evaluation step limits |
| 46 | #if TEST_STD_VER > 20 |
| 47 | static_assert(test()); |
| 48 | #endif |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | |