Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / template.bitset / bitset.members / all.pass.cpp
blob8b27ffc7795e0f1cbc0cae4cc91d8e989f436592
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 all() 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_all() {
19 std::bitset<N> v;
20 v.reset();
21 assert(v.all() == (N == 0));
22 v.set();
23 assert(v.all() == true);
24 if (v.size() > 1) {
25 v[N/2] = false;
26 assert(v.all() == false);
30 TEST_CONSTEXPR_CXX23 bool test() {
31 test_all<0>();
32 test_all<1>();
33 test_all<31>();
34 test_all<32>();
35 test_all<33>();
36 test_all<63>();
37 test_all<64>();
38 test_all<65>();
39 test_all<1000>();
41 return true;
44 int main(int, char**) {
45 test();
46 #if TEST_STD_VER > 20
47 static_assert(test());
48 #endif
50 return 0;