|
Boost Users : |
Subject: Re: [Boost-users] Needs advices on design ( mpl or processor )
From: Nevin Liber (nevin_at_[hidden])
Date: 2012-01-06 17:04:43
On 6 January 2012 13:26, Larry Evans <cppljevans_at_[hidden]> 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/log2.html>
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_at_[hidden]> (847) 691-1404
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net