Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we use template to pass not only function pointer, but lambda, functor or something else? #74

Open
LittleDogXi opened this issue Jul 5, 2024 · 1 comment

Comments

@LittleDogXi
Copy link

LittleDogXi commented Jul 5, 2024

In cminpack, two types of function pointer are used. For example, as for hybrd, we could pass a function pointer to it, which is like
void(*fun)(const int *n, const real *x, real *fvec, int *iflag) or int (*fun)(void *p, int n, const real *x, real *fvec, int iflag). The void *p in the latter type is used to pass additional parameters without using global variables.
But if we want to use lambda, functor, or something else, we cannot make it. So, why not use some templates, so that we are not only able to pass a static type function pointer to hybrd, but also lambda, functor or other stuff.

@devernay
Copy link
Owner

devernay commented Jul 7, 2024

The underlying code is C, and I'm not sure how to call a lambda from C. This goes beyond my C++expertise. If you find a way to make it work without breaking the C API, please submit a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants