So according to https://en.cppreference.com/w/cpp/thread/thread/thread: the copy constructor for std::thread
is deleted and is the reason I cannot do (results in a compilation error):
std::thread t1;
std::thread t2 = t1;
However I am somehow able to do:
std::thread t1;
t1 = std::thread();
I was under the impression that the above code creates a temporary std::thread
object and copies it into t1
but the copy constructor doesn't exist (as is shown in the top snippet which doesn't compile).
So what exactly is going on in the second snippet?