
On 6 January 2012 13:26, Larry Evans
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