Philippe Després wrote:
Hello,
I am using Numerical Recipes routines and I am trying to call this function
I wouldn't advise using any of that source code. It's not good C++ code and the licence fees could get expensive. See http://www.accu.org/cgi-bin/accu/rvout.cgi?from=0ti_n&file=n003134a for more information.
void mrqmin(Vec_I_DP &x, Vec_I_DP &y, Vec_I_DP &sig, Vec_IO_DP &a, Vec_I_BOOL &ia, Mat_O_DP &covar, Mat_O_DP &alpha, DP &chisq, void funcs(const DP, Vec_I_DP &, DP &, Vec_O_DP &), DP &alamda);
and I would like to call it with funcs being a member function pointer of one of my class. I can declare the member as static but then I cannot access member variable, which is the goal here.
You can access static member variables.
Someone suggested to use boost to solve the problem. <snip>
Boost doesn't have a solution to this problem. Boost.Bind and
Boost.Function help you to adapt functions, but they produce function
objects that are of no use with a function that requires a function
pointer, such as the C-style code found in Numerical Recipes. Functions
that call-back through function pointers should always pass through an
arbitrary context pointer. This allows you to define a static member
function like this:
void my_class::my_callback(void * context, other args...)
{
static_cast