Bit Logic > functions > set_bits
set_bits
Syntax:
  #include <boost/bit_logic/functions.hpp> 
  void set_bit ( BitStorage bit_store, size_type bit_idx ) ; 
  void set_bits ( BitStorage bit_store, size_type upper_bit_idx, size_type lower_bit_idx ) ; 

The set_bits functions are used to set to 1 any bits within a bit_storage type. The naming diffence is used to denote setting of 1 bit within a bit_storage type versus setting a sequence of bits.

For example:

  uint16_t test = 0 ; 
  set_bit ( test, 0 ) ; 
  cout << test << endl ;
  set_bits ( test, 7, 1 ) ;
  cout << test << endl ;

This code will output:

  1
  255

This code can throw the following exceptions :

Exceptions:
std::logic_error index range incorrect
bit_logic::out_of_bounds Indexing out of bounds of bit_storage type