problem integrating lambda and gsl
I am writing some code that involves several uses of the gnu scientific library that I am trying to streamline using boost lambda. I am having some newbie problems with some rather lengthy compiler errors. Here's a fairly minimal set description of my problem. First I have a functor class that does some relatively complicated processing: class functor : public std::unary_function<double,double> { public: double operator()(double x) const { // do some work here return something; } } For use with the gsl, I have created a wrapper to make this linto something that can be handled by the gsl routines: template<class func> double gslfunc(double x, void* p) { func* f = reinterpret_cast<functor*>(p); return (*f)(p); } I now have the following function that allows me to use gsl routines: template<class func> double myRoutine(func& f) { gsl_function F; F.function = &gslfunc<functor>; F.params = reinterpret_cast<void*>(&f); // call some gsl routines with the gsl_function return something; } I can now use gsl routines on the above functor with no difficulty. What I would like to be able to do is use lambda expressions to make slight modifications to the underlying functor, for example take the following code snippet: functor f; myRoutine(bind(f,_1)+1); However, this dies a horrible death upon compilation complaining that there is no available conversion from the type that is generated by bind(f,_1)+1 to void*. I suspect that there is no way to get a pointer to a lambda'd function and that this is causing my problem. Am I correct? I would happy to provide any more details about what I am doing or the gsl bindings if that would be helpful. Thanks for your consideration. Luke Shulenburger (shulenbu@uiuc.edu)
participants (1)
-
Luke Shulenburger