[memprof] Move YAML traits to MemProf.h (NFC) (#118668)
[llvm-project.git] / libcxx / test / std / utilities / template.bitset / bitset.operators / op_and.pass.cpp
blob792f1fa453031b244d88fc06be5a8266bdc30356
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 //===----------------------------------------------------------------------===//
9 // bitset<N> operator&(const bitset<N>& lhs, const bitset<N>& rhs); // constexpr since C++23
11 #include <bitset>
12 #include <cassert>
13 #include <cstddef>
14 #include <vector>
16 #include "../bitset_test_cases.h"
17 #include "test_macros.h"
19 template <std::size_t N>
20 TEST_CONSTEXPR_CXX23 void test_op_and() {
21 std::vector<std::bitset<N> > const cases = get_test_cases<N>();
22 for (std::size_t c1 = 0; c1 != cases.size(); ++c1) {
23 for (std::size_t c2 = 0; c2 != cases.size(); ++c2) {
24 std::bitset<N> v1 = cases[c1];
25 std::bitset<N> v2 = cases[c2];
26 std::bitset<N> v3 = v1;
27 assert((v1 & v2) == (v3 &= v2));
32 TEST_CONSTEXPR_CXX23 bool test() {
33 test_op_and<0>();
34 test_op_and<1>();
35 test_op_and<31>();
36 test_op_and<32>();
37 test_op_and<33>();
38 test_op_and<63>();
39 test_op_and<64>();
40 test_op_and<65>();
42 return true;
45 int main(int, char**) {
46 test();
47 test_op_and<1000>(); // not in constexpr because of constexpr evaluation step limits
48 #if TEST_STD_VER > 20
49 static_assert(test());
50 #endif
52 return 0;