c – 为什么商店出现原子unique_ptr导致崩溃?
发布时间:2020-12-16 10:12:02 所属栏目:百科 来源:网络整理
导读:该代码在i7-4790处理器(x86-64)上的VC 2013(v120)下编译没有问题. int main(){ std::atomicstd::unique_ptrint p; p.store(std::make_uniqueint(5));} 一旦main()返回,我就会崩溃: Expression: _BLOCK_TYPE_IS_VALID(pHead-nBlockUse) 这是怎么回事? 解决
该代码在i7-4790处理器(x86-64)上的VC 2013(v120)下编译没有问题.
int main() { std::atomic<std::unique_ptr<int>> p; p.store(std::make_unique<int>(5)); } 一旦main()返回,我就会崩溃:
这是怎么回事? 解决方法
您无法使用std :: unique_ptr实例化std :: atomic.
cppreference
并且
您可以使用具有free functions defined to allow you to have atomic stores and loads的 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |