第二种情况有什么问题?从我看到的GCC和Clang支持的情况下。
有不确定的行为吗?STD:: vector构造函数#5
指定它可能是由于该元素不是可构造的,但是在这种情况下,第一个元素也不会给出错误吗?
有与constexpr相关的东西?可能还有其他吗?我在编译错误中看到以下内容:
error: use of deleted function 'std::jthread::jthread(const std::jthread&)'
std::jthread
具有阐释构建器。因此:
auto lambda = [] {
std::cout << "New thread during initialization" << std::endl;
};
std::jthread t1 = lambda; // impossible
std::jthread t2 = std::jthread(lambda); // possible
std::initializer_list<>
,类型必须为std::jthread