I would like to assign a name to a thread, the thread itself must do this. The thread is a class member of the class foo. I would like to start this thread with a lambda but unfortunately I get the error message: no match for call to '(std::thread) (foo::start()::<lambda()>)
Can someone explain to me where the problem is? Previously I had created a temporary thread object, and put this with move on the thread "manage", however, I can then give no name.
class foo { public: int start() { this->manage([this](){ auto nto_errno = pthread_setname_np(manage.native_handle(),"manage"); // Give thread an human readable name (non portable!) while(1){ printf("do work"); } }); return 1; } private: int retVal; std::thread manage; };