C++ boost::与boost::asio绑定在一起。boost::bind不起作用,从示例中复制
有人能告诉我为什么这个不能编译吗?我基本上是从2007年Kholkoff()的一个例子中复制过来的,关于带超时的套接字中的reads():C++ boost::与boost::asio绑定在一起。boost::bind不起作用,从示例中复制,c++,boost,boost-asio,boost-bind,C++,Boost,Boost Asio,Boost Bind,有人能告诉我为什么这个不能编译吗?我基本上是从2007年Kholkoff()的一个例子中复制过来的,关于带超时的套接字中的reads(): void CClient::setResult(boost::optional<boost::system::error_code>* a,boost::system::error_code b) { *a = b; } gcc打印的错误我无法读取: static assertion f
void CClient::setResult(boost::optional<boost::system::error_code>*
a,boost::system::error_code b)
{
*a = b;
}
gcc打印的错误我无法读取:
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::_bi::unspecified, void (CClient::*)(boost::optional<boost::system::error_code>*, boost::system::error_code), boost::_bi::list2<boost::_bi::value<boost::optional<boost::system::error_code>*>, 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>*, 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::_bi::unspecified, void (CClient::*)(boost::optional<boost::system::error_code>*, boost::system::error_code), boost::_bi::list2<boost::_bi::value<boost::optional<boost::system::error_code>*>, 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
静态断言失败:WaitHandler类型要求未满足远程\u服务器第499行,外部位置:/usr/include/boost/asio/basic\u deadline\u timer.hpp C/C++问题
调用(boost::_bi::bind_t)(const boost::system::error_code&)远程服务器第499行,外部位置不匹配:/usr/include/boost/asio/basic_deadline_timer.hpp C/C++问题
“void(CClient::*)(boost::optional*,boost::system::error_code)”不是类、结构或联合类型远程_服务器第69行,外部位置:/usr/include/boost/bind/bind.hpp C/C++问题
make:**没有将目标设置为“全部”的规则。C/C++问题
make:**[src/CClient.o]错误1远程\u服务器C/C++问题
“类boost::_bi::bind_t”远程服务器第15行,外部位置:/usr/include/boost/bind/bind_template.hpp C/C++问题中需要
此处需要CClient.cpp/remote_server/src行93 C/C++问题
那么
timer.async_wait(boost::bind(&CClient::setResult, this, &timer_result, _1));
setResult
是成员函数,如果您在CClient
中使用async\u wait
,或者使用CClient
类型的某个对象而不是this
如何
timer.async_wait(boost::bind(&CClient::setResult, this, &timer_result, _1));
setResult
是成员函数,如果在CClient
中使用async\u wait
,或者使用CClient
类型的对象,而不是this
在这种情况下,值得一提的是this
必须是CClient
类型。在这种情况下,值得一提的是this
必须是CClient
类型。请将您的错误输出格式化为四个缩进的代码空间。这将导致难以读取的输出,并使其变得更糟。请将错误输出格式化为代码缩进四个空格的格式。这会占用难以读取的输出并使其变得更糟。