I'm using an API call from a library that takes a void function(void)
pointer as a parameter
static inline void attach(void(*userFunc)(void));
And I have a class Button
with a member method void buttonClicked()
.
What I want is to basically make a static function dynamically at runtime that will be like:
void functionForThisSpecificObject(){
theSpecificObject.buttonClicked();
}
I tried with a lambda like this:
Button* self = this;
attach([self](){self->buttonClicked();});
But then it can't be used as a static function pointer because it is a capturing lambda...
I don't want to create a static function for every object that I will be using manually, so how can this be done dynamically?
Thank you in advance for any help.