xref: /llvm-project/libcxx/test/std/utilities/template.bitset/bitset.members/reset_one.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(size_t pos); // 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 TEST_MSVC_DIAGNOSTIC_IGNORED(6294) // Ill-defined for-loop:  initial condition does not satisfy test.  Loop body not executed.
20 
21 template <std::size_t N>
test_reset_one()22 TEST_CONSTEXPR_CXX23 void test_reset_one() {
23     std::vector<std::bitset<N> > const cases = get_test_cases<N>();
24     for (std::size_t c = 0; c != cases.size(); ++c) {
25         for (std::size_t i = 0; i != N; ++i) {
26             std::bitset<N> v = cases[c];
27             v.reset(i);
28             assert(v[i] == false);
29         }
30     }
31 }
32 
test()33 TEST_CONSTEXPR_CXX23 bool test() {
34   test_reset_one<0>();
35   test_reset_one<1>();
36   test_reset_one<31>();
37   test_reset_one<32>();
38   test_reset_one<33>();
39   test_reset_one<63>();
40   test_reset_one<64>();
41   test_reset_one<65>();
42 
43   return true;
44 }
45 
main(int,char **)46 int main(int, char**) {
47   test();
48   test_reset_one<1000>(); // not in constexpr because of constexpr evaluation step limits
49 #if TEST_STD_VER > 20
50   static_assert(test());
51 #endif
52 
53   return 0;
54 }
55