
On 01/07/12 17:28, Larry Evans wrote:
On 01/07/12 02:42, Allan Nielsen wrote: [snip]
void example1() { // As you see, the expresions for calculating the offset get quite long, // and are not easy to maintain.
Here's where I don't understand why the calculation are done outside the temple and then passed as args to the template. Why not have a template do the calculations and accumulate the results, somewhat like mpl::fold or the code I posted earlier?
C< CompressedEnum
, CompressedEnum
::offset * CompressedEnum ::size >, CompressedEnum
CompressedEnum
::offset * CompressedEnum ::size >::offset * CompressedEnum ::offset * CompressedEnum ::size >::size > > c1; }
[snip] The attached code produces output:
:eos_t::offset=9
:get_ol(T1)=2
:get_ol(T2)=0
:get_ol(T3)=0
:get<T3>=0
putting:
:get<T1>=0
:get<T2>=1
:get<T3>=2
The output before the putting: lines is caused by the obviously
erroneous initialization of the buffer (no Enum e's stored in
the buffer, only unsigned ints). The output after the putting: lines
shows the effect of the put