我正在尝试使用创建线程std::async
,但我不断收到错误“没有匹配函数调用'<code>async(std::launch,<unresolved 重载函数类型>,std::string&)'”在线
ConnectFuture = std::async(std::launch::async, Connect_T,ip);
这是产生这种行为的代码:
#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;
}