升压asiodeadline_timer
async_wait
函数正在采用以下形式的处理程序:
void handler(const boost::system::error_code& error)
我如何定义一个处理程序来接收const boost::system::error_code& error
还有一个类型参数int
?
boost::asio::deadline_timer t(io_service);
t.async_wait(handler); //I need the async_wait to take in handler which accepts argument boost::system::error_code& error and an int
void handler(int, const boost::system::error_code& error )//extra int argument
Thanks.
你可以使用升压绑定 http://www.boost.org/doc/libs/1_45_0/libs/bind/bind.html为第一个参数提供值:
t.async_wait(boost::bind(handler, 0, _1));
在这里,将使用 0 作为第一个参数来调用处理程序error_code
将简单地作为第二个参数转发。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)