Bit Logic > functions > test_bit
test_bit
Syntax:
 #include <boost/bit_logic/functions.hpp>
 bool test_bit ( BitStorageT const & value, std::size_t bit_idx ) ;						  

Returns true if the bit offset within the Bit Storage type is set to 1.

For example:

  uint32_t some_value = 0xdead;
  if ( test_bit ( some_value, 5 ) ) { 
    cout << "Someone set Bit 5" << endl ; 						  
  }						

This code would produce this output:

  Someone set Bit 5
Exceptions:
bit_logic::out_of_bounds Indexing out of bounds of bit_storage type