generate an n-deep runtime for loop

Hello, I have a fusion sequence of optionals, for e.g. fusion::vector< optional< variant< std::vector<double>, triplet<double>, pair<double>, double> >, optional< variant< std::vector<int>, triplet<int>, pair<int>, int> >, optional< variant< std::vector<double>, triplet<double>, pair<double>, double> >
The size of fusion::vector is variable. The optionals are never empty. In 1 possible instance of this fusion vector, we have these runtime values { 5.5, 10.1, 15.7, 30.9 //std::vector<double> v1 5:15:5 // triplet<int> range from 5 to 10 incrementing with 4 5.4 // double, value fixed at 5.4 } I wish to generate at runtime the following code (not always 3-deep for loops, the 3 would be known at compile time, but the bounds of the indices in the for loops are only known at runtime) for (size_t index1=0; index1< v1.size(); ++index1) { for (int index2=5; index2<=15; index2+=5) { for (double index3=5.4; index3<=5.4; ++index3) { // some code } } } is this possible? regards,

<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
Hicham Mouline wrote: then call itself while incrementing the mpl::int_. Terminal case stop the for loop generation and generate the inner body. -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35

----- Original Message -----
From: "joel falcou"
<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
Hicham Mouline wrote: 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

----- Original Message -----
From: "joel falcou"
<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
Hicham Mouline wrote: then call itself while incrementing the mpl::int_. Terminal case stop the for loop generation and generate the inner body.
I have a fusion sequence (const Seq& seq), and during the recursion process, I want to process the front element, then pass to the next step, the remainder of the seq. I can't seem to find the algorithm for this, rds,

----- Original Message -----
From: "joel falcou"
Hicham Mouline wrote:
Please refer to the first post of this thread for the initial question. I believe the compiler got stuck in an infinite loop of template instantiations from my code. It hasn't stopped printing instantiation backtraces when I interrupted it and never reached printing the actuall error :-) The code is ///@param params_seq fusion::vector< variant<>, variant<>, ...., variant<>
///@param body a callable that takes a parameters_t const-ref as an argument
///
template

----- Original Message -----
From: "joel falcou"
Hicham Mouline wrote: I believe the compiler got stuck in an infinite loop of template instantiations from my code. It hasn't stopped printing instantiation backtraces when I interrupted it and never reached printing the actuall error :-)
instead of using mpl integral constants as template argument, I used size_t, then the recursion terminates at 0. The n-deep for loop generation works perfectly well, fantastic. A later stage refinement will be parallelization of the whole n-deep for loop (I'll try openmp). regards,
participants (2)
-
Hicham Mouline
-
joel falcou