
My problem is not to calculate the actually size, but move the
calculation from the instantiation into the definition of the library.
On Fri, Jan 6, 2012 at 11:04 PM, Nevin Liber
On 6 January 2012 13:26, Larry Evans
wrote: So, IIUC, you want (as the name compressed_enums suggests) want to sum the sizes of each enum,
Assuming size is the number of unique values in a given enum, you want to sum the ceiling of log2 of the size of each enum to determine how many bits you need. http://www.boost.org/doc/libs/1_48_0/libs/integer/doc/html/boost_integer/log... can help with this (although it computes floor(log2(n))). Note: to get an even denser packing where different enums can share the same bit, remove "ceiling of" from the previous sentence.
Example: if the first enum has 4 distinct values and the second enum has 8 distinct values, you need to be about to store 4x8=32 distinct combinations. ceil(log2(4)) + ceil(log2(8)) == 2 + 3 == 5 bits. -- Nevin ":-)" Liber mailto:nevin@eviloverlord.com (847) 691-1404 _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users