[英]“no matching function for call to ‘async(std::launch, <unresolved overloaded function type>, std::string&)’”
I am trying to create a thread using std::async
, but I keep getting the error "no matching function for call to ' async(std::launch, <unresolved overloaded function type>, std::string&)
'" on the line 我正在尝试使用
std::async
创建一个线程,但我不断收到错误“没有匹配函数来调用' async(std::launch, <unresolved overloaded function type>, std::string&)
'”线
ConnectFuture = std::async(std::launch::async, Connect_T,ip);
Here is the code that produces this behaviour: 以下是产生此行为的代码:
#include <future>
class libWrapper
{
public:
void Connect(std::string ip);
void Connect_T(std::string ip);
private:
std::future<void> ConnectFuture;
};
void libWrapper::Connect(std::string ip){
auto status = ConnectFuture.wait_for(std::chrono::seconds(0));
if (status != std::future_status::timeout)
{
ConnectFuture = std::async(std::launch::async, Connect_T,ip);
}
}
void libWrapper::Connect_T(std::string ip)
{
}
int main(int argc, char** argv) {
libWrapper lW;
lW.Connect("192.168.3.1");
return 0;
}
It's a member function, so it needs an object to be called on as well as an argument. 它是一个成员函数,因此它需要一个对象被调用以及一个参数。 Maybe it should be static, or maybe you should bind it to
this
: 也许它应该是静态的,或者你应该将它绑定到
this
:
std::async(std::launch::async, &libWrapper::Connect_T, this, ip)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.