I have class foo. The bar
method used to be static and I was able to create new threads with the code below. I
class foo
{
public:
static void bar(std::unique_ptr<std::vector<std::string>> pData)
{
// do things here
}
};
auto pDdata = std::unique_ptr<std::vector<std::string>>(new std::vector<std::string>);
std::thread newThread = std::thread(&foo::bar, std::move(pData));
Then I changed the bar
method a little. Notice that due to the size_data
declaration, bar
is no longer static.
void bar(std::unique_ptr<std::vector<std::string>> pData)
{
unsigned short int size_data = pData.get()->size();
// do things here
}
At this point, the compiler started giving an error.
/usr/include/c++/7/thread:240:2: error: no matching function for call to ‘std::thread::_Invoker<std::tuple<void ...
Then, I tried changing
std::thread newThread = std::thread(foo::bar, ...)
and I started receiving the following error.
error: invalid use of non-static member function
I'm not sure what's wrong. Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire