Boost Users :
Subject: Re: [Boost-users] Needs advices on design ( mpl or processor )
From: Larry Evans (cppljevans_at_[hidden])
Date: 2012-01-07 06:56:08
On 01/06/12 13:26, Larry Evans wrote:
> So, IIUC, you want (as the name compressed_enums suggests) want to
> sum the sizes of each enum, then create a buffer with at least that
> number of bits, and then check that that buffer size is <
> I've thought some more about the problem and started coding something;
> however, it's not complete, but you may be able to complete it.
> As it is, it just prints 3, which is:
> BTW, the attached code uses variadic templates; however, I'm guessing
> you could easily use non-variadic template compiler after some
> code changes.
The attached code is a revision of the previously posted code.
It does not properly calculate the size of the storage needed
for the compressed enums; however, IIUC this could easily be
corrected using Nevin Liber's suggestion about using log2.
The int enums_offsets<>::buffer in the real code would
be what you've called:
in your OP. As mentioned, the size is incorrect but that's
The revised code also illustrates the use of CRTP to allow access
of the super types to the storage buffer. These super types
use the overloaded get's with the proper TAG argument to
access the proper portion of the buffer.
The output of the attached is:
and was compiled with gcc4.7.
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