[mlir][acc] Introduce MappableType interface (#122146)
[llvm-project.git] / libcxx / test / std / utilities / template.bitset / bitset.members / any.pass.cpp
blobf53a527c1fea38fb0520aad58e114153f07523a8
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 //===----------------------------------------------------------------------===//
9 // bool any() const; // constexpr since C++23
11 #include <bitset>
12 #include <cassert>
13 #include <cstddef>
15 #include "test_macros.h"
17 template <std::size_t N>
18 TEST_CONSTEXPR_CXX23 void test_any() {
19 std::bitset<N> v;
20 v.reset();
21 assert(v.any() == false);
22 v.set();
23 assert(v.any() == (N != 0));
24 if (v.size() > 1) {
25 v[N/2] = false;
26 assert(v.any() == true);
27 v.reset();
28 v[N/2] = true;
29 assert(v.any() == true);
33 TEST_CONSTEXPR_CXX23 bool test() {
34 test_any<0>();
35 test_any<1>();
36 test_any<31>();
37 test_any<32>();
38 test_any<33>();
39 test_any<63>();
40 test_any<64>();
41 test_any<65>();
42 test_any<1000>();
44 return true;
47 int main(int, char**) {
48 test();
49 #if TEST_STD_VER > 20
50 static_assert(test());
51 #endif
53 return 0;