I'm trying to register a callback in a C-API that uses the standard function-pointer+context paradigm. Here's what the api looks like:
void register_callback(void(*callback)(void *), void * context);
What I'd really like to do is be able to register a C++ lambda as the callback. Additionally, I want the lambda to be one that has captured variables (ie. can't be converted to a straight stateless std::function)
What kind of adapter code would I need to write to be able to register a lambda as the callback?