是否有使用“ new”关键字在堆上初始化std::thread的方法?
std::thread
不要使用新的,请使用make_unique
make_unique
沿着这条线的东西:
#include<thread> #include<memory> bool fun1() { return true; } int main() { auto thread1 = std::make_unique<std::thread>( fun1 ); thread1->join(); }