xref: /llvm-project/libcxx/test/std/utilities/template.bitset/bitset.members/set_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>& set(); // 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_set_all()18 TEST_CONSTEXPR_CXX23 void test_set_all() {
19     std::bitset<N> v;
20     v.set();
21     for (std::size_t i = 0; i < v.size(); ++i)
22         assert(v[i]);
23 }
24 
test()25 TEST_CONSTEXPR_CXX23 bool test() {
26   test_set_all<0>();
27   test_set_all<1>();
28   test_set_all<31>();
29   test_set_all<32>();
30   test_set_all<33>();
31   test_set_all<63>();
32   test_set_all<64>();
33   test_set_all<65>();
34   test_set_all<1000>();
35 
36   return true;
37 }
38 
main(int,char **)39 int main(int, char**) {
40   test();
41 #if TEST_STD_VER > 20
42   static_assert(test());
43 #endif
44 
45   return 0;
46 }
47