|
Boost Users : |
Subject: Re: [Boost-users] fusion struct adapt macro, construct the struct from a fusion vector
From: Hicham Mouline (hicham_at_[hidden])
Date: 2010-01-19 22:43:13
----- Original Message -----
From: "Joel de Guzman" <joel_at_[hidden]>
To: <boost-users_at_[hidden]>
Sent: Wednesday, January 20, 2010 9:48 AM
Subject: Re: [Boost-users] fusion struct adapt macro, construct the struct
from a fusion vector
> On 1/20/2010 2:05 AM, Hicham Mouline wrote:
>
>> Following my previous attempt, replacing the functor applied by foreach
>> to the zipped sequence by:
>>
>> struct assignelt {
>>
>> template <typename T>
>> void operator()( const vector2<const T&, const T&>& seqpairs ) const
>> {
>> typedef vector2<const T&, const T&> pair_t;
>> const_cast<T&>(at_c<0, const pair_t>(seqpairs)) = at_c<1, const
>> pair_t>(seqpairs);
>> }
>> };
>> works.
>>
>> I can now construct my struct params from an equivalent fusion sequence.
>> This constructor is identical for all my params struct.
>> I have structs params1 to params100
>>
>> Is there a way to factorise this ctor and not repeat its definition in
>> the 100 struct params?
>> Is this possible with a base struct templated on the derived struct?
>
> Wow. 100! Anyway, I've seem to lost context already. Pardon me, I'm
> not following this thread well. Could you rephrase the problem again
> in simpler terms?
>
> Regards,
Yes, something in that order. We are testing systems and we don't know which
will give the best results.
With your and Hartmut's help, I wrote a constructor for my struct pararms
that takes a fusion sequence as an argument:
template<typename Seq>
params( const Seq& seq, ... )
{
for_each( zip(*this, seq), assignelt() );
}
params is adapted to be a fusion sequence.
assignelt() is the functor that assigns from seq to params with the help of
the zipped sequence
Now, my question was whether the ctor could be refactored because it is
identical for all the 100 params structs.
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