Hi,

I have a struct adapted as a fusion sequence. My user inputs at runtime the index of the member she is interested in.

 

Assuming all members are convertible to double, the only solution I found so far is:

 

double f(unsigned index)

{

  switch(index) {

  case 0: return boost::fusion::at_c<0>( sequence );

  case 1: return boost::fusion::at_c<1>( sequence );

  case 6: return boost::fusion::at_c<6>( sequence );

  }

}

 

To generate this:

1.       0 to fusion::result_of::size<Seq>::type::value – 1 is the range I want.

2.       I can’t use PP to generate the cases inside the switch

3.       Can I generate an array of function pointers to the various at<>() functions and call the right one at runtime?

 

I am basically looking for the runtime version of at_c.

 

Regards,