简体   繁体   中英

compiler error when calling a std::thread function with parameters C++

I am trying to invoke a function from a new thread. The function takes a bunch of parameters.

std::thread signingThread(curlWrapper->SendDataToServer,username, password, serverURL, data);

Here is the function protoype

int LibCurlWrapper::SendDataToServer(const std::string& username, const std::string& password, const std::string& serverURL, const std::vector<unsigned char> &vData)

Compiler Error

error: no matching function for call to 'std::thread::thread(, std::string&, std::string&, std::string&, std::vector&)' std::thread signingThread(curlWrapper->SendDataToServer,username, password, serverURL, data);

You need to specify a function to std::thread , while curlWrapper->SendDataToServer doesn't and couldn't. (Although curlWrapper->SendDataToServer() means call SendDataToServer() on curlWrapper .)

Change it to:

std::thread signingThread(&LibCurlWrapper::SendDataToServer, curlWrapper, username, password, serverURL, data);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM