|
|
1
12
正如您正确观察到的,async_wait方法接受一个处理函数,该函数接受一个参数(const boost::system::error_code&)。但在Timer.4示例中,对async_wait的调用通过boost bind传递,如下所示:
bind返回一个引用方法的函数对象 打印 上课 打印机 这 . 此函数对象由async_wait方法使用error参数调用(因为这是它期望的签名)。但是错误参数被默默忽略,因为绑定没有引用它。 boost::bind documentation 提供有关boost::bind的更多详细信息。另见文章 How the Boost Bind Library Can Improve Your C++ Programs |
|
|
2
2
在对async_wait的调用中,可以使用占位符指定回调函数的参数。检查链接页面上async_wait调用上方的句子:
在中搜索“占位符” this example 你将看到如何做到这一点。 |