c++11 std::thread 和 std::bind 请教,成员函数的参数是另一个成员函数
資深大佬 : auto8888 1
成员函数:
void Adas::udpBind(unsigned short LocalPort,void (Adas::*fun)(std::string))
在构造函数里:
std::bind(&Adas::udpBind,this,this->LocalPort,&Adas::readStatus) 这编译 OK 。
但是
std::thread thread1(std::bind(&Adas::udpBind,this,this->LocalPort,&Adas::readStatus));
thread1.join();
编译失败了。
std::thread 类成员函数(成员函数的参数还有成员函数,有点绕,汗)不能作为线程函数吗?
还是我写法有问题啊
void Adas::udpBind(unsigned short LocalPort,void (Adas::*fun)(std::string))
在构造函数里:
std::bind(&Adas::udpBind,this,this->LocalPort,&Adas::readStatus) 这编译 OK 。
但是
std::thread thread1(std::bind(&Adas::udpBind,this,this->LocalPort,&Adas::readStatus));
thread1.join();
编译失败了。
std::thread 类成员函数(成员函数的参数还有成员函数,有点绕,汗)不能作为线程函数吗?
还是我写法有问题啊
大佬有話說 (10)