
Its somewhat off-topic, and I didn't post the code for this class, because its complicated, but
bitfield<big, 3, 6, -21, 9>
means four consecutive unsigned integer bit fields with widths of 3, 6, 21, and 9 bits, respectively,
Presumably, based on your explanation, you mean 3 unsigned bit fields and one signed one. Seems neat. One question though - is this supposed to swap the "bitfields" (i.e. is this a generalized endian bit swapper) or is the intent to have a bitfield which then gets treated as one "larger" type and gets swapped byte-wise?
My point was that I don't think of endianess as being a "swapping" problem, but an "ordering" problem. The bit-endianness of messages makes this clear for me, since swapping doesn't work.
I would be interested in knowing what you'd think about implementing the swapping using the user defined type endian swapping facility in my library. At first sight, it seems like it should be possible. Tom