|
Boost Users : |
Subject: Re: [Boost-users] generate an n-deep runtime for loop
From: Hicham Mouline (hicham_at_[hidden])
Date: 2010-01-21 23:50:07
----- Original Message -----
From: "joel falcou" <joel.falcou_at_[hidden]>
To: <boost-users_at_[hidden]>
Sent: Friday, January 22, 2010 1:41 AM
Subject: Re: [Boost-users] generate an n-deep runtime for loop
> Hicham Mouline wrote:
>> <snip>
>> is this possible?
> Yes,
> you'll need to build a recursive function that takes your vector and an
> mpl::int_ as a n arguments, geenrate a for loop on current fusion element
> then call itself while incrementing the mpl::int_. Terminal case stop
> the for loop generation and generate the inner body.
>
I am gonna try this:
/// Seq is fusion::vector< optional< variant<> >, optional< variant<> >,
...., optional< variant<> > >
/// InnerBody is a callable that takes as many arguments as there are
elements in the Seq
template <typename Seq, typename InnerBody, template MplIntegral>
void for_recurse(const Seq& seq, const InnerBody& body)
{
// check requirements are compile time
// generate the for loop
// for each iteration, call for_recurse with seq reduced
}
//partial specialization for the 0 case
template <typename Seq, typename InnerBody>
void for_recurse< mpl::int_<0> >(const Seq& seq, const InnerBody& body)
{
body( ... ); // somehow call body with all the arguments accumulated so
far , how?
}
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