I tried using the std::ptr_fun to wrap my function, but when I try to wrap a function with void parameter and bool return type I end up with an error:
code:
std::function<bool()> cr = std::not1(std::ptr_fun(&funct1));
function:
bool funct1()
{
return false;
}
the error:
error: no matching function for call to 'ptr_fun(bool (*)())'
but whenever I change the parameter to int, the problem seems to go away.
how do I wrap a function with a void parameter?
std::ptr_fun
only works on unary functions: functions with exactly one parameter.
bool funct1();
is not a unary function, it is a nullary function. There is no such thing as a void parameter. The syntax bool funct1(void);
inherited from C is just a strange way of saying there are no parameters at all.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.