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 bitset<N>& set(size_t pos, bool val = true); 11 12 #include <bitset> 13 #include <cassert> 14 15 template <std::size_t N> test_set_one()16void test_set_one() 17 { 18 std::bitset<N> v; 19 try 20 { 21 v.set(50); 22 if (50 >= v.size()) 23 assert(false); 24 assert(v[50]); 25 } 26 catch (std::out_of_range&) 27 { 28 } 29 try 30 { 31 v.set(50, false); 32 if (50 >= v.size()) 33 assert(false); 34 assert(!v[50]); 35 } 36 catch (std::out_of_range&) 37 { 38 } 39 } 40 main()41int main() 42 { 43 test_set_one<0>(); 44 test_set_one<1>(); 45 test_set_one<31>(); 46 test_set_one<32>(); 47 test_set_one<33>(); 48 test_set_one<63>(); 49 test_set_one<64>(); 50 test_set_one<65>(); 51 test_set_one<1000>(); 52 } 53