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