
On 01/07/12 02:42, Allan Nielsen wrote:
On Sat, Jan 7, 2012 at 1:54 AM, Larry Evans
wrote: On 01/06/12 16:19, Allan Nielsen wrote:
My problem is not to calculate the actually size, but move the calculation from the instantiation into the definition of the library. I have not idea what this means. Please clarify.
First of all, thanks for your input.
I will try to illustrate my design problem in a more simple example:
struct TagA { enum Size { size = 4 }; enum E { A0 = 0, A1 = 1, A2 = 2, A3 = 3, }; };
struct TagB { enum Size { size = 4 }; enum E { B0 = 0, B1 = 1, B2 = 2, B3 = 3, }; };
struct TagC { enum Size { size = 4 }; enum E { C0 = 0, C1 = 1, C2 = 2, C3 = 3, }; };
// Simple edition of CompressedEnum, but has the same problem
Sorry, what was that problem again?
template
struct CompressedEnum { enum O { offset = OFFSET }; enum S { size = T::size }; T get( ) { ... } }; // Simple edition of CompressedEnums, but has the same problem template < typename B0, typename B1, typename B2 > struct CompressedEnums: public B0, B1, B2 { template < typename T> get() { ... } };
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] -regards, Larry