1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // test bool any() const; 11 12 #include <bitset> 13 #include <type_traits> 14 #include <cassert> 15 16 template <std::size_t N> test_any()17void test_any() 18 { 19 std::bitset<N> v; 20 v.reset(); 21 assert(v.any() == false); 22 v.set(); 23 assert(v.any() == (N != 0)); 24 const bool greater_than_1 = std::integral_constant<bool, (N > 1)>::value; // avoid compiler warnings 25 if (greater_than_1) 26 { 27 v[N/2] = false; 28 assert(v.any() == true); 29 v.reset(); 30 v[N/2] = true; 31 assert(v.any() == true); 32 } 33 } 34 main()35int main() 36 { 37 test_any<0>(); 38 test_any<1>(); 39 test_any<31>(); 40 test_any<32>(); 41 test_any<33>(); 42 test_any<63>(); 43 test_any<64>(); 44 test_any<65>(); 45 test_any<1000>(); 46 } 47