简体   繁体   English

“没有匹配函数来调用'async(std :: launch,<unresolved overloaded function type>,std :: string&)'”

[英]“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.

相关问题 错误:没有匹配函数来调用...(std :: string&) - error: no matching function for call to…(std::string&) 没有用于调用std :: transform,未解析的重载函数类型的匹配函数 - No matching function for call to std::transform, unresolved overloaded function type 没有匹配的函数来调用&#39;std :: list <int, std::allocator<int> &gt; :: sort( <unresolved overloaded function type> )&#39; - No matching function for call to 'std::list<int, std::allocator<int> >::sort(<unresolved overloaded function type>)' 错误:没有匹配函数可调用&#39;isupper(std :: string&)&#39;| - error: no matching function for call to 'isupper(std::string&)'| 错误:没有用于调用“getline(FILE*&amp;, std::string&amp;)”的匹配函数 - error: no matching function for call to 'getline(FILE*&, std::string&)' C++ 多线程错误:没有匹配的 function 调用 'std::thread::thread(<unresolved overloaded function type></unresolved> - C++ Multithreading Error : no matching function for call to 'std::thread::thread(<unresolved overloaded function type> 如何解决错误:“没有匹配的函数来调用&#39;bind( <unresolved overloaded function type> 在类中使用std :: bind时 - How to solve the error: “no matching function for call to ‘bind(<unresolved overloaded function type>” when std::bind is used in a class 没有匹配的函数来调用&#39;bind( <unresolved overloaded function type> ,const std :: _ Placeholder &lt;1&gt;&,int *) - no matching function for call to ‘bind(<unresolved overloaded function type>, const std::_Placeholder<1>&, int*) 字符串的排列-错误:没有匹配的函数来调用&#39;std :: set <char> :: insert(std :: string&)&#39; - Permutations of a string --error: no matching function for call to ‘std::set<char>::insert(std::string&)’ 没有匹配的 function 调用 'std::vector::push_back(std::string&amp;)' - No matching function for call to ‘std::vector::push_back(std::string&)’
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM