Home | History | Annotate | Download | only in bitset.members
      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 all() const;
     11 
     12 #include <bitset>
     13 #include <type_traits>
     14 #include <cassert>
     15 
     16 template <std::size_t N>
     17 void test_all()
     18 {
     19     std::bitset<N> v;
     20     v.reset();
     21     assert(v.all() == (N == 0));
     22     v.set();
     23     assert(v.all() == true);
     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.all() == false);
     29     }
     30 }
     31 
     32 int main()
     33 {
     34     test_all<0>();
     35     test_all<1>();
     36     test_all<31>();
     37     test_all<32>();
     38     test_all<33>();
     39     test_all<63>();
     40     test_all<64>();
     41     test_all<65>();
     42     test_all<1000>();
     43 }
     44