This question seems to have been asked numerous times before, for example here1, here2 and here3.
What I am trying to do is, set the member function
of the C-Struct gsl_function
to a member function of my class.
class MyClass{
double foo(double x)
{
return ...;
}
double bar(double x)
{
...
gsl_function F;
// Problem I cant do this (compiler error)
F.function = &(this->foo);
}
};
The third link above provides a solution, I think it is based on the wrapper approach described here4.
So my question is can I do better. Is there an easier way? For example, possibly by using Boost's function and Bind objects.
I am weighing up the option of using a gsl wrapper, such as o2scl. But am a bit releuctant as I may pay the price later if the wrapper is not well maintained. Any suggestions?