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// bool all() const; // constexpr since C++23
10
11#include <bitset>
12#include <cassert>
13#include <cstddef>
14
15#include "test_macros.h"
16
17template <std::size_t N>
18TEST_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);
27 }
28}
29
30TEST_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>();
40
41 return true;
42}
43
44int main(int, char**) {
45 test();
46#if TEST_STD_VER > 20
47 static_assert(test());
48#endif
49
50 return 0;
51}
52

source code of libcxx/test/std/utilities/template.bitset/bitset.members/all.pass.cpp