title: How can I pass a C++ lambda to a C-callback that expects a function pointer and a context?
body: <p>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:</p>
  
  <pre><code>void register_callback(void(*callback)(void *), void * context);
  </code></pre>
  
  <p>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 <code>std::function</code>)</p>
  
  <p>What kind of adapter code would I need to write to be able to register a lambda as the callback?</p>