[英]C++ ptr_fun not finding void parameterized functions
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: 我尝试使用std :: ptr_fun来包装我的函数,但是当我尝试用void参数和bool返回类型包装函数时,我最终得到一个错误:
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 (*)())' 错误:没有匹配函数来调用'ptr_fun(bool(*)())'
but whenever I change the parameter to int, the problem seems to go away. 但每当我将参数更改为int时,问题似乎就消失了。
how do I wrap a function with a void parameter? 如何用void参数包装函数?
std::ptr_fun
only works on unary functions: functions with exactly one parameter. std::ptr_fun
仅适用于一元函数:只有一个参数的函数。
bool funct1();
is not a unary function, it is a nullary function. 不是一元函数,它是一个虚函数。 There is no such thing as a void parameter. 没有void参数这样的东西。 The syntax bool funct1(void);
语法bool funct1(void);
inherited from C is just a strange way of saying there are no parameters at all. 继承自C只是一种奇怪的方式,说根本没有参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.