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 // test bool any() const; 10 11 #include <bitset> 12 #include <type_traits> 13 #include <cassert> 14 15 #include "test_macros.h" 16 17 template <std::size_t N> 18 void test_any() 19 { 20 std::bitset<N> v; 21 v.reset(); 22 assert(v.any() == false); 23 v.set(); 24 assert(v.any() == (N != 0)); 25 const bool greater_than_1 = std::integral_constant<bool, (N > 1)>::value; // avoid compiler warnings 26 if (greater_than_1) 27 { 28 v[N/2] = false; 29 assert(v.any() == true); 30 v.reset(); 31 v[N/2] = true; 32 assert(v.any() == true); 33 } 34 } 35 36 int main(int, char**) 37 { 38 test_any<0>(); 39 test_any<1>(); 40 test_any<31>(); 41 test_any<32>(); 42 test_any<33>(); 43 test_any<63>(); 44 test_any<64>(); 45 test_any<65>(); 46 test_any<1000>(); 47 48 return 0; 49 } 50