如何自动重置shared_ptr?

时间:2017-06-15 09:19:05

标签: c++ shared-ptr atomic

我们有atomic accessshared_ptr但我无法看到如何以原子方式重置它们:我缺少什么?

1 个答案:

答案 0 :(得分:3)

You can just use atomic_exchange with a default constructed shared_ptr:

atomic_exchange(&ptr, {});