I try to get the size of a bitfield.
For example, I have got a generic handle:
template<size_t n, size_t m>
struct handle
{
uint32 index : n;
uint32 validation : m;
}
Now I want to get the size of the members.
I found a macro that works when I have a handle<16, 16>
and expands the desired members to sizeof
. In this case, if I pass in the index
members I get 16
as my output.
But there I would have to pass in my output variable.
Is there a way maybe with some template magic to expand directly to the desired number? So I could pass in sizeof_bit(class, member)
and I get the sizebit
size of this member?