I am trying to use a method from a library that requires a function pointer as an input (of the type double (*)(const double)
). The problem is that the function needs to have access to a few more values.
double f(vector<double> a) {
return lib_func(std::bind(g, a, _1));
}
double g(vector<double> a, double x) {
return a[0] + x;
}
What I need is a function double h(double x) { return a[0] + x; }
, but I have been unable to create it of the type that the library function requires. (I have tried bind, lambda functions, creating a class or struct so that the function has access to the parameters, etc.).
I am relatively new to C++, so I am not sure what the type double (*)(const double)
is.
Aucun commentaire:
Enregistrer un commentaire