-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Larry Evans Sent: 09 February 2010 18:11 To: boost-users@lists.boost.org Subject: Re: [Boost-users] generate structs with all combinations of members from a given struct
Hmmm. What about multi_array_base being the S_empty:
struct S_empty{};
IOW, this would be the 32nd version of S. Your PP method now generates 31 versions, you could just add the 32 version be S_empty.
This makes sense because each time a field is added, it's like a derived class. IOW, S_empty would be the base class, and all other classes would be derived from it. I vaguely remember reading about that somewhere, IOW, that adding a field to a class is sorta like restricting the class is sorta like deriving from that class. It's not the Ss themselves that I need to derive from a base class to transport through translation units. It's boost::multi_array
that I need to transport anonymously. And that is why I wrap the multi_array in a struct that derives from multi_array_base.
I have say 5 translation units tr1,tr2,tr3,tr4 and tr5.
The specific multi_array is generated in tr1. It needs to pass via tr2,tr3 and tr4 to reach tr5. tr2,3 and 4 do not need to know what exact multi_array type it is, so they just deal with multi_array_base. tr5 then dynamic casts the multi_array_base ref to the appropriate multi_array with the appropriate S.
pseudo_code tr1, itself geenrate switch( bitset.toulong() ) { case 1: some_function( multi_array_adapted_to_derive_from_base
& ); case 2: some_function( multi_array_adapted_to_derive_from_base & ); .... case 63: some_function( multi_array_adapted_to_derive_from_base & ); } This is still work in progress.
I'd be interesting in seeing this code when you're done with it. I'd like to try using:
composite_tagged_seq < all_of_aligned , field_I1 , field_I2 ... , field_In
where field_I1...field_In is some subset of S::field1,...field5 and composite_tagged is from composite_tagged_seq.zip in the boost vault:
http://www.boostpro.com/vault/index.php?&directory=Data Structures
Then compare the compile-time and run-time performance. I've no doubt it would be slower than the PP version, but I'm just curious about how much.
-regards, Larry I will definitely compare as well once I understand what you mean.
I have another problem for now.
PP processing is starting to be slow, I need help to optimize it. Attached
in the PP code.
Also, in the above, all the Ss need to be generated only once.
However, in multi_array