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 none() const;
     11 
     12 #include <bitset>
     13 #include <type_traits>
     14 #include <cassert>
     15 
     16 template <std::size_t N>
     17 void test_none()
     18 {
     19     std::bitset<N> v;
     20     v.reset();
     21     assert(v.none() == true);
     22     v.set();
     23     assert(v.none() == (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.none() == false);
     29         v.reset();
     30         v[N/2] = true;
     31         assert(v.none() == false);
     32     }
     33 }
     34 
     35 int main()
     36 {
     37     test_none<0>();
     38     test_none<1>();
     39     test_none<31>();
     40     test_none<32>();
     41     test_none<33>();
     42     test_none<63>();
     43     test_none<64>();
     44     test_none<65>();
     45     test_none<1000>();
     46 }
     47