How could I pass std::function as function pointer?
I am trying to write a class template and internally it use a C function (implementation of BFGS optimization, provided by the R environment) with the following interface: void vmmin(int n, double *x, double *Fmin, optimfn fn, optimgr gr, ... , void *ex, ... ); where fn and gr are function pointers of type typedef double optimfn(int n, double *par, void *ex); and typedef void optimgr(int n, double *par, double *gr, void *ex); respectively. My C++ class template looks like this: template <typename T> class optim { public: // ... void minimize(T& func, arma::vec &dpar, void *ex) { std::function