1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // bitset(unsigned long long val); // constexpr since C++23
13 #include <algorithm> // for 'min' and 'max'
16 #include "test_macros.h"
18 TEST_MSVC_DIAGNOSTIC_IGNORED(6294) // Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed.
20 template <std::size_t N
>
21 TEST_CONSTEXPR_CXX23
void test_val_ctor()
24 TEST_CONSTEXPR
std::bitset
<N
> v(0xAAAAAAAAAAAAAAAAULL
);
25 assert(v
.size() == N
);
26 std::size_t M
= std::min
<std::size_t>(v
.size(), 64);
27 for (std::size_t i
= 0; i
< M
; ++i
)
28 assert(v
[i
] == ((i
& 1) != 0));
29 for (std::size_t i
= M
; i
< v
.size(); ++i
)
30 assert(v
[i
] == false);
32 #if TEST_STD_VER >= 11
34 constexpr std::bitset
<N
> v(0xAAAAAAAAAAAAAAAAULL
);
35 static_assert(v
.size() == N
, "");
40 TEST_CONSTEXPR_CXX23
bool test() {
49 test_val_ctor
<1000>();
58 static_assert(test());