I wanted to pass a function taking as argument and returning a void *
to another function. Right now i have the following code:
MyClass *MyClass::bind(std::function<void*(void *)> fun) {
this->value = fun(this->value);
return this;
}
value
is a void *
variable inside MyClass
, i can't figure out how to pass a function to my function bind
.
When i try to pass it the name of a function like this
auto *class = new MyClass();
class->bind(fooFunction);
i get the error
no viable conversion from '<overloaded function type>' to 'std::function<void *(void *)>'
Is there any way to achieve what i want with this code or does an easier approach exist?
Aucun commentaire:
Enregistrer un commentaire