Boost logo

Boost Users :

Subject: [Boost-users] generate an n-deep runtime for loop
From: Hicham Mouline (hicham_at_[hidden])
Date: 2010-01-21 13:26:29


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,



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