I'm trying to create a "guarded_thread", but I receive an error 'operator=' is a private member of 'std::__1::thread'. Here is my code:
struct guarded_thread : std::thread{
using std::thread::thread;
using std::thread::operator=;
~guarded_thread(){if(joinable())join();}
};
A function did the work, but I want to know how to create it the other way
void Guarded_thread(std::thread &Thread){
if (Thread.joinable()) {
Thread.join();
}
}