std::atomic可以通过以下方式进行自减操作:

  1. 使用operator--()函数:
std::atomic<int> a(10);
a.operator--();
  1. 使用fetch_sub()函数:
std::atomic<int> a(10);
a.fetch_sub(1);
  1. 使用--运算符重载:
std::atomic<int> a(10);
--a;

以上三种方法都可以进行std::atomic的自减操作。

stdatomicint如何进行自减?

原文地址: https://www.cveoy.top/t/topic/nJg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录