我不知道如何创建以下内容:
std::pair<std::atomic<bool>, int>
Run Code Online (Sandbox Code Playgroud)
我总是总是得到
/usr/include/c++/5.5.0/bits/stl_pair.h:139:45:错误:使用已删除的功能'std :: atomic :: atomic(const std :: atomic&)'
:第一(__x),第二(std :: forward <_U2>(__ y)){}
我试过了
std::pair<std::atomic<bool>, int> pair = std::make_pair(true, 1); //doesn't work
std::pair<std::atomic<bool>, int> pair = std::make_pair({true}, 1); //doesn't work
std::pair<std::atomic<bool>, int> pair = std::make_pair(std::atomic<bool>(true), 1); //doesn't work
std::pair<std::atomic<bool>, int> pair = std::make_pair(std::move(std::atomic<bool>(true)), 1); //doesn't work
Run Code Online (Sandbox Code Playgroud)
我知道std :: atomic是不可复制的,那么您应该如何成对创建它?只是不可能吗?