Bit Logic > functions > flip_bits
flip_bits
Syntax:
 #include <boost/bit_logic/functions.hpp>
 void flip_bit ( BitStorageT & value, std::size_t bit_idx ) ;
 void flip_bits ( BitStorageT & value, std::size_t upper_bit_idx, std::size_t lower_bit_idx ) ;

Invert individual bit, or bit range in Bit Storage type.

For example:

  uint32_t some_value = 0u;
  flip_bits ( some_value, 31,16 ) ;
  cout << hex << some_value << endl ;

This code would produce this output:

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