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 none() 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_none() 19 { 20 std::bitset<N> v; 21 v.reset(); 22 assert(v.none() == true); 23 v.set(); 24 assert(v.none() == (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.none() == false); 30 v.reset(); 31 v[N/2] = true; 32 assert(v.none() == false); 33 } 34 } 35 36 int main(int, char**) 37 { 38 test_none<0>(); 39 test_none<1>(); 40 test_none<31>(); 41 test_none<32>(); 42 test_none<33>(); 43 test_none<63>(); 44 test_none<64>(); 45 test_none<65>(); 46 test_none<1000>(); 47 48 return 0; 49 } 50