您如何在堆上初始化线程? (使用“新”关键字)

是否可以使用“ new”关键字在堆上初始化std::thread

duoluoyouhun 回答:您如何在堆上初始化线程? (使用“新”关键字)

不要使用新的,请使用make_unique

此行的内容:

#include<thread>
#include<memory>

bool fun1()
{
    return true;
}

int main() {
    auto thread1 = std::make_unique<std::thread>( fun1 );


    thread1->join();
}
本文链接:https://www.f2er.com/3017112.html

大家都在问