I have a function pointer type imported from another .hpp file. Something like:
typedef void (*PFN_func)(int i);
I want to create a functor of the same type:
std::function<PFN_func>
But this doesn't work. I don't want a solution like
std::function<void(int)>
Because mt function pointer definition is much more complicated
You could do this:
std::function<std::remove_pointer<PFN_func>::type>
Removing the pointer from void (*)(int) gives the function type void(int).
For the case of a general callable, see Is it possible to figure out the parameter type and return type of a lambda?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With