std::thread对象移动

//临时对象转移,必须隐式调用
t1=std::thread(some_other_function);
std::thread t3;
t3=std::move(t2);//显式调用
t1=std::thread(some_other_function);
t1=std::move(t3);//多次赋值将使程序崩溃
//std::thread 实例作为参数进行传递
void f(std::thread t);
void g()
{
    void some_function();
    f(std::thread(some_function));
    std::thread t(some_function);
    f(std::move(t));
}


猜你喜欢

转载自blog.csdn.net/qq_41741165/article/details/80593749