xref: /llvm-project/libcxx/test/std/utilities/template.bitset/bitset.members/reset_all.pass.cpp (revision f02120fba28f2352fd9396683892fc6671caa137)
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>& reset(); // constexpr since C++23
10 
11 #include <bitset>
12 #include <cassert>
13 #include <cstddef>
14 
15 #include "test_macros.h"
16 
17 template <std::size_t N>
test_reset_all()18 TEST_CONSTEXPR_CXX23 void test_reset_all() {
19     std::bitset<N> v;
20     v.set();
21     v.reset();
22     for (std::size_t i = 0; i < v.size(); ++i)
23         assert(!v[i]);
24 }
25 
test()26 TEST_CONSTEXPR_CXX23 bool test() {
27   test_reset_all<0>();
28   test_reset_all<1>();
29   test_reset_all<31>();
30   test_reset_all<32>();
31   test_reset_all<33>();
32   test_reset_all<63>();
33   test_reset_all<64>();
34   test_reset_all<65>();
35   test_reset_all<1000>();
36 
37   return true;
38 }
39 
main(int,char **)40 int main(int, char**) {
41   test();
42 #if TEST_STD_VER > 20
43   static_assert(test());
44 #endif
45 
46   return 0;
47 }
48