jeudi 28 mars 2019

Passing lambas as callbacks to C functions

Suppose I have a C function

typedef void (* callback_t)(void* data);
register_callback(callback_t callback, void* data);

and I want to pass a lambda as the callback.

What's the idiomatic way to do this...

  1. When the lambda captures nothing?
  2. When the lambda has captures (by value, by reference etc.)?

Aucun commentaire:

Enregistrer un commentaire