|
Boost Users : |
Subject: Re: [Boost-users] generate structs with all combinations of members from a given struct
From: Hicham Mouline (hicham_at_[hidden])
Date: 2010-02-09 17:12:38
> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Larry Evans
> Sent: 09 February 2010 18:11
> To: boost-users_at_[hidden]
> 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<S_..., N> 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<appropriate_S, appropriate_M>&
> );
> > case 2: some_function(
> > multi_array_adapted_to_derive_from_base<appropriate_S, appropriate_M>&
> );
> > ....
> > case 63: some_function(
> > multi_array_adapted_to_derive_from_base<appropriate_S, appropriate_M>&
> );
> > }
> >
> > 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<S..., N>, the N depends on the translation unit.
I will have like 100 translation units, each with a different N.
If I were to include the PP code to generate the Ss in each of the 100 trs,
it would repeat the preprocessing uselessly.
I need to run the first part of the PP just once, then the 2nd part of the
PP that generates the multi_arrays for each of the 100 tr units.
Is this possible?
Regards,
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