A bridge for convert c++ function object to c function pointer (with user pointer)
Have you ever lost your head in passing a function to the C interface? Are you still fighting against void *
? With funcptr, you no longer have to worry about passing C++ functions in the C interface
void some_c_interface(int arg, void(*callback)(int input, void *user), void *user);
using namespace func_ptr;
int captured;
funcptr lambda{[&](int input /* Normal parameter */, user_pointer /* Use this for user pointer placeholder */) { process(input, captured); }};
some_c_interface(arg /* Normal parameter */, lambda, lambda.holder() /* User pointer */);
It support
- Pass normal function to c interface (Not recommanded, please pass it directly)
- Pass std::function to c interface
- Pass lambda and std::bind
All funcptr
- Add a asm magic for pass c++ function to c interface that no user pointer.
Unlicensed see LICENSE;