|
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 13:05:58
----- Original Message -----
From: "Hicham Mouline" <hicham_at_[hidden]>
To: <boost-users_at_[hidden]>
Sent: Tuesday, January 19, 2010 4:22 PM
Subject: Re: [Boost-users] fusion struct adapt macro,construct the struct
from a fusion vector
>> What about:
>>
>> template <typename Seq>
>> params(Seq const& seq,
>> typename boost::enable_if<
>> fusion::traits::is_sequence<Seq>
>> >::type* = NULL);
>>
>> ?
>
> Fantastic.
>
> Here is the code I have (plz see below), but it seems there are issues
> with const-ness that I don't understand.
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?
rds,
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