Bit Logic > assign > any
any
Syntax:
  #include <boost/bit_logic/assign.hpp> 
  bit_any_functor any ( BitType bit_store ) ; 

The any function returns a functor object whose operator() member functions test if any bit is set individually, or within a range of bits of the constructed Bit Type. The bit_any_functor object is convertible to bool, and has short circuit evaluation, so after first true value is found all further calls are executed in constant time.

For example:

  uint16_t some_val = 0x0fe5 ; 
  if ( (any)(15,12)(8)(2)(0) ) cout << endl ;
  else cout << "Correct Answer!" << endl ;

This code will output:

  Correct Answer!

This syntactic form can also be used for single bit assginments.

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
bit_logic::runtime_error functor object destruction with out any operator's being called