Skip to content

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

@LittleDogXi

Description

@LittleDogXi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions