calling function objects in a fusion vector
Hi all! I'm starting to play with boost::fusion and I am amazed by its power - thanks for the library, its great! Nevertheless, I ran into some trouble: I have fusion vector of function objects which all have the same arity and take the same arguments. Now I want to call each function object via the fusion::invoke method, as I have the arguments also on in a fusion vector, so something like this: typedef fusion::vector< binary_function1, binary_function2, ...> funcVec; typedef fusion::vector< double, int > argType; funcVec funs; argType args(0.5, 3); Now my idea was to use boost::bind to do the trick like this: boost::transform(funcVec, bll::bind(&fusion::invoke<>, _1, args)); However, this does not work - the bind complains about unresolved overloaded function type. So, what is wrong here? Thanks a lot in advance for any help. Greetings, Sebastian Weber
Sebastian Weber wrote:
boost::transform(funcVec, bll::bind(&fusion::invoke<>, _1, args));
However, this does not work - the bind complains about unresolved overloaded function type. So, what is wrong here?
Extracting function pointer from function template is difficult. In this case, it seems even impossible. BTW, Boost.Egg: http://p-stade.sourceforge.net/boost/libs/egg/ supports "fusing", which turns function into one taking a FusionSequence. // \f -> fuse(f)(args) lazy(lazy(fuse)(bll::_1))(args) Or, this might be more readable. // \f -> apply(fuse(f), args) lazy(apply)(lazy(fuse)(bll::_1), args) Regards, -- Shunsuke Sogame
participants (2)
-
Sebastian Weber
-
shunsuke