I have a function that takes as an argument CallbackType
, which is
typedef (*void) (const *char, bool)
I need to pass additional context, so I thought it would be a good idea to use lambdas:
CallbackType DelegateHandler(Pointer ptr) {
return [&](const char* a, bool b) {
callback(ptr, a, b);
};
}
It only works though if it's a capturing lambda, and a capturing lambda cannot be converted to a regular function pointer, so I get the error:
no known conversion for argument 1 from SetHandler(Pointer)::<lambda(const char*, bool)>’ to ‘CallbackType’ {aka ‘void(*)(const char*, bool)’
Any idea how to solve this in a simple fashion?