i did a class for multithread:
Code:
class Multithread
{
private:
pthread_t threads;
std::function<void(void)> setf;
void *multithreadproc(void*)
{
//call the function
setf();
}
public:
Multithread(std::function<void(void)> SetFunction)
{
setf=SetFunction;
}
void call()
{
pthread_create(&threads, NULL,std::bind(multithreadproc, this, std::placeholders::_1));//error
}
Multithread operator()()
{
pthread_create(&threads, NULL,std::bind(multithreadproc, this, std::placeholders::_1), (void*)1);
return this;
}
~Multithread()
{
pthread_exit(NULL);
setf=nullptr;
}
};
see(for exemple) the method call:
Code:
pthread_create(&threads, NULL,std::bind(multithreadproc, this, std::placeholders::_1));
i'm trying use the function name on 3rd parameter. but the function is from these class, so i think that i must use bind(). but i get these error:
"no matching function for call to 'bind(<unresolved overloaded function type>, Multithread* const, const std::_Placeholder<1>&)'"
what i'm doing wrong?