stdatomicint如何进行自减?
std::atomic
- 使用operator--()函数:
std::atomic<int> a(10);
a.operator--();
- 使用fetch_sub()函数:
std::atomic<int> a(10);
a.fetch_sub(1);
- 使用--运算符重载:
std::atomic<int> a(10);
--a;
以上三种方法都可以进行std::atomic
原文地址: https://www.cveoy.top/t/topic/nJg 著作权归作者所有。请勿转载和采集!