|
select
Syntax:
#include <boost/bit_logic/assign.hpp> bit_select_functor select ( BitType bits ) ; The select function returns a functor object whose operator() member functions are used to call select on ranges of bit within its constructed Bit Type. The bit_select_functor return object is convertible to a bit_vector object for assignment. The object itself can be assigned from any type convertible to a bit_vector. For example: uint16_t test = 0xbabe ; select(test) = select(test)(7,0)(15,8) ; cout << hex << test << endl ; This code will swap the "upper" and "lower" bytes of data word, and will output: beba This same behavior can also be expressed like this : select(test)(7,0)(15,8) = test ; In the first example the range of all bits are selected, because no operator() member functions was called on the lhs argument. The bit_select_functor returned on the lhs is assigned to a type that is convertiable to a bit_vector, which is the swapped order of bits in the test object. Both of these version will need to create a temporary object to contain the bits while bits are being moved. This is necessary to preserve the integrity of the bits in the container. At this time all assignments are converted or copied to bit_vector's before being assigned. Nota Bene: A future enhancement will be only applying this copying technique when the source and destination types cannot alias to the same data. Exceptions:
|