提高::用的boost :: ASIO绑定在一起。提高::绑定不工作,从一个例子复制 [英] boost::bind together with boost::asio. boost::bind not working, copied from an example
问题描述
有人能告诉我为什么这个不能编译?我基本上是从一个例子复制它由Kholkoff(http://lists.boost.org/Archives/boost/2007/04/120339.php),早在2007年,大约读()的插座与超时:
Could someone tell me why this does not compile? I basically copied it from an example by Kholkoff (http://lists.boost.org/Archives/boost/2007/04/120339.php), back in 2007, about reads() in sockets with timeouts:
void CClient::setResult(boost::optional<boost::system::error_code>*
a,boost::system::error_code b)
{
*a = b;
}
我绑定(),它是这样的:
I'm binding() it like this:
timer.async_wait(boost::bind(&CClient::setResult, &timer_result, _1));
这GCC打印不可读对我的错误:
The errors that gcc prints are unreadable to me:
描述资源路径位置类型
静态断言失败:WaitHandler类型的要求没有得到满足remote_server的线499,外部位置:/usr/include/boost/asio/basic_deadline_timer.hpp C / C ++问题
敌不过呼叫(提高:: _双:: bind_t)(升压::可选,提振::系统::错误_ code),提振:: _双::列表2 *>,提振:: ARG&LT; 1 >>>)(常量的boost ::系统::错误_ code&安培;)'remote_server的线499,外部位置:/usr/include/boost/asio/basic_deadline_timer.hpp C / C ++问题
无效(CClient :: )(升压::可选的的,提振::系统::错误_ code)'不是一个类,结构或联合类型remote_server的第69行,外部位置: /usr/include/boost/bind/bind.hpp C / C ++问题
令: *无规则,使目标`所有'。 C / C ++问题
令:* [来源/ CClient.o]错误1 remote_server的C / C ++问题
从类boost :: _双:: bind_t)要求(升压::可选,提振::系统::错误_ code),提振:: _双::列表2 *>,提振:: ARG&LT; 1>>> remote_server的第15行,外部位置:/usr/include/boost/bind/bind_template.hpp C / C ++问题
从这里需要CClient.cpp / remote_server的/ src目录线路93 C / C ++问题
Description Resource Path Location Type static assertion failed: WaitHandler type requirements not met remote_server line 499, external location: /usr/include/boost/asio/basic_deadline_timer.hpp C/C++ Problem no match for call to ‘(boost::_bi::bind_t)(boost::optional, boost::system::error_code), boost::_bi::list2*>, boost::arg<1> > >) (const boost::system::error_code&)’ remote_server line 499, external location: /usr/include/boost/asio/basic_deadline_timer.hpp C/C++ Problem ‘void (CClient::)(boost::optional, boost::system::error_code)’ is not a class, struct, or union type remote_server line 69, external location: /usr/include/boost/bind/bind.hpp C/C++ Problem make: * No rule to make target `all'. C/C++ Problem make: * [src/CClient.o] Error 1 remote_server C/C++ Problem required from ‘class boost::_bi::bind_t)(boost::optional, boost::system::error_code), boost::_bi::list2*>, boost::arg<1> > >’ remote_server line 15, external location: /usr/include/boost/bind/bind_template.hpp C/C++ Problem required from here CClient.cpp /remote_server/src line 93 C/C++ Problem
推荐答案
和如何对
timer.async_wait(boost::bind(&CClient::setResult, this, &timer_result, _1));
的setResult
是成员函数,如果在 CClient $ C使用
async_wait
$ C>,或使用类型的某些对象 CClient
而不是这个
。
setResult
is member function, if you use async_wait
in CClient
, or use some object of type CClient
instead of this
.
这篇关于提高::用的boost :: ASIO绑定在一起。提高::绑定不工作,从一个例子复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!