Boost logo

Boost Users :

From: Vjekoslav Brajkovic (balkan_at_[hidden])
Date: 2008-07-29 19:58:27


Hi,

   I am somewhat new to Boost Fusion and MPI, therefore I apologize if I am
   asking a trivial question (I wasn't able to the answer). I have a map of
   <mpl::int_<N>, boost::function> pairs. Each integer is a command, and based
   on that command I would like call some specific function. However, after
   debugging through the code, I have realized that the callbacks are not
   compile time. So, I was wondering if anybody could tell me if there is a way
   of modifying my code in such a manner that there is no run-time overhead
   associated with map indexing. Here is an example code.

////////10////////20////////30////////40////////50////////60////////70////////80

int main(int argc, char* argv[]) {

   boost::function<void (int)> _int_1_;
   boost::function<void (std::string)> _int_2_;

   _int_1_ = &fun_1;
   _int_2_ = &fun_2;

   { using boost::fusion::map;
     using boost::mpl::int_;

     boost::fusion::result_of::make_map<int_<1>, int_<2>,
     boost::function<void (int)>,
     boost::function<void (std::string)>
>::type fmap;

   boost::fusion::at_key< int_<1> >(fmap) = _int_1_;
   boost::fusion::at_key< int_<1> >(fmap)(5);

   }


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