C++ 参考手册
- C++11
- C++14
- C++17
- C++20
- C++ 编译器支持情况表
- 独立与宿主实现
- C++ 语言
- C++ 关键词
- 预处理器
- C++ 标准库头文件
- 具名要求
- 功能特性测试 (C++20)
- 工具库
- 类型支持(基本类型、RTTI、类型特性)
- 概念库 (C++20)
- 错误处理
- 动态内存管理
- 日期和时间工具
- 字符串库
- 容器库
- 迭代器库
- 范围库 (C++20)
- 算法库
- 数值库
- 输入/输出库
- 文件系统库
- 本地化库
- 正则表达式库
- 原子操作库
- std::atomic
- std::atomic<T>::atomic
- std::atomic<T>::operator=
- std::atomic<T>::is_lock_free
- std::atomic<T>::is_always_lock_free
- std::atomic<T>::store
- std::atomic<T>::load
- std::atomic<T>::operator T()
- std::atomic<T>::exchange
- std::atomic<T>::compare_exchange_weak, std::atomic<T>::compare_exchange_strong
- std::atomic<T>::wait
- std::atomic<T>::notify_one
- std::atomic<T>::notify_all
- std::atomic<T>::fetch_add
- std::atomic<T>::fetch_sub
- std::atomic<T>::fetch_and
- std::atomic<T>::fetch_or
- std::atomic<T>::fetch_xor
- std::atomic<T>::operator++,++(int),--,--(int)
- std::atomic<T>::operator+=,-=,&=,|=,^=
- std::atomic_store, std::atomic_store_explicit
- std::atomic_load, std::atomic_load_explicit
- std::atomic_exchange, std::atomic_exchange_explicit
- std::atomic_flag
- std::atomic_ref
- std::atomic_compare_exchange_weak, std::atomic_compare_exchange_strong, std::atomic_compare_exchange_weak_explicit, std::atomic_compare_exchange_strong_explicit
- std::atomic_fetch_add, std::atomic_fetch_add_explicit
- std::atomic_fetch_sub, std::atomic_fetch_sub_explicit
- std::atomic_fetch_and, std::atomic_fetch_and_explicit
- std::atomic_fetch_or, std::atomic_fetch_or_explicit
- std::atomic_fetch_xor, std::atomic_fetch_xor_explicit
- std::atomic_is_lock_free, ATOMIC_xxx_LOCK_FREE
- std::atomic_wait, std::atomic_wait_explicit
- std::atomic_notify_one
- std::atomic_notify_all
- std::atomic_flag_test_and_set, std::atomic_flag_test_and_set_explicit
- std::atomic_flag_clear, std::atomic_flag_clear_explicit
- std::atomic_flag_test, std::atomic_flag_test_explicit
- std::atomic_flag_wait, std::atomic_flag_wait_explicit
- std::atomic_flag_notify_one
- std::atomic_flag_notify_all
- std::atomic_init
- ATOMIC_VAR_INIT
- ATOMIC_FLAG_INIT
- std::memory_order
- std::kill_dependency
- std::atomic_thread_fence
- std::atomic_signal_fence
- 注释
- 线程支持库
- 实验性 C++ 特性
- 有用的资源
- 索引
- std 符号索引
- 协程支持 (C++20)
- C++ 关键词
位置:首页 > C++ 参考手册 >原子操作库 >std::atomic > std::atomic<T>::operator++,++(int),--,--(int)
std::atomic<T>::operator++,++(int),--,--(int)
T operator++() noexcept; T operator++() volatile noexcept; |
(1) | (仅为 atomic<Integral> 模板特化的成员)(C++11 起) |
T* operator++() noexcept; T* operator++() volatile noexcept; |
(1) | (仅为 atomic<T*> 模板特化的成员)(C++11 起) |
T operator++( int ) noexcept; T operator++( int ) volatile noexcept; |
(2) | (仅为 atomic<Integral> 模板特化的成员)(C++11 起) |
T* operator++( int ) noexcept; T* operator++( int ) volatile noexcept; |
(2) | (仅为 atomic<T*> 模板特化的成员)(C++11 起) |
T operator--() noexcept; T operator--() volatile noexcept; |
(3) | (仅为 atomic<Integral> 模板特化的成员)(C++11 起) |
T* operator--() noexcept; T* operator--() volatile noexcept; |
(3) | (仅为 atomic<T*> 模板特化的成员)(C++11 起) |
T operator--( int ) noexcept; T operator--( int ) volatile noexcept; |
(4) | (仅为 atomic<Integral> 模板特化的成员)(C++11 起) |
T* operator--( int ) noexcept; T* operator--( int ) volatile noexcept; |
(4) | (仅为 atomic<T*> 模板特化的成员)(C++11 起) |
原子地自增或自减当前值。操作为读-修改-写操作。
1) 进行原子前自增。等价于 fetch_add(1)+1 。
2) 进行原子后自增。等价于 fetch_add(1) 。
3) 进行原子前自减。等价于 fetch_sub(1)-1 。
4) 进行原子后自减。等价于 fetch_sub(1) 。
对于有符号整数 (Integral
) 类型,算术定义为使用补码表示。无未定义结果。对于 T*
类型,结果可能为未定义地址,但这些操作不会另有未定义行为。
参数
(无)
返回值
注意
不同于大多数前自增和自减运算符,原子类型的前自增和自减运算符不返回被修改对象的引用。它们替而返回存储值的副本。
参阅
原子地将参数加到存储于原子对象的值,并返回先前保有的值 (公开成员函数) | |
原子地从存储于原子对象的值减去参数,并获得先前保有的值 (公开成员函数) | |
加、减,或与原子值进行逐位与、或、异或 (公开成员函数) |