I've been looking into the idea of using a bitset to store a collection of
fields efficiently in a data structure that uses a large number of elements.
My question is what technique is used to extract subsets of the bitset and
use them in normal types? How would i extract bits 3 - 10 inclusive of a
bitset and store them in a char, for example, or how could I go about
treating some bitset elements as a char value or any other atomic data type
for that matter, if that is a better way of wording the question? I know
about the bitwise operators but am not quite sure how to go about achieving
this. Obviously, I am assuming that the STL class bitset really will save
me space and it wont be too slow extracting values rather than using a
structure with bool values, char, long etc as needed, though i am not happy
about how much space that might use.
thanks for any help or advice :)
This doesn't answers your specific questions, but since you're
also asking about even achieving it, perhaps it'll suffice as
a starting point: http://www.comeaucomputing.com/techtalk/#getbinary
--
Greg Comeau/4.3.3:Full C++03 core language + more Windows backends
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?