C++ 参考手册
- C++11
- C++14
- C++17
- C++20
- C++ 编译器支持情况表
- 独立与宿主实现
- C++ 语言
- C++ 关键词
- 预处理器
- C++ 标准库头文件
- 具名要求
- 功能特性测试 (C++20)
- 工具库
- 类型支持(基本类型、RTTI、类型特性)
- 概念库 (C++20)
- 错误处理
- 动态内存管理
- 日期和时间工具
- 字符串库
- 容器库
- 迭代器库
- 范围库 (C++20)
- 算法库
- 数值库
- 输入/输出库
- 文件系统库
- 本地化库
- 正则表达式库
- 原子操作库
- std::atomic
- std::atomic_flag
- std::atomic_ref
- std::atomic_ref<T>::atomic_ref
- std::atomic_ref<T>::operator=
- std::atomic_ref<T>::is_lock_free
- std::atomic_ref<T>::store
- std::atomic_ref<T>::load
- std::atomic_ref<T>::operator T
- std::atomic_ref<T>::exchange
- std::atomic_ref<T>::compare_exchange_weak, std::atomic_ref<T>::compare_exchange_strong
- std::atomic_ref<T>::wait
- std::atomic_ref<T>::notify_one
- std::atomic_ref<T>::notify_all
- std::atomic_ref<T>::is_always_lock_free
- std::atomic_ref<T>::required_alignment
- std::atomic_ref<T>::fetch_add
- std::atomic_ref<T>::fetch_sub
- std::atomic_ref<T>::fetch_and
- std::atomic_ref<T>::fetch_or
- std::atomic_ref<T>::fetch_xor
- std::atomic_ref<T>::operator++,++(int),--,--(int)
- std::atomic_ref<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_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_ref > std::atomic_ref<T>::exchange
std::atomic_ref<T>::exchange
T exchange( T desired, std::memory_order order = std::memory_order_seq_cst ) const noexcept; |
(C++20 起) | |
原子地以 desired
替换被引用对象的值。该操作是读修改写操作。按照 order
的值影响内存。
参数
desired | - | 要赋值的值 |
order | - | 要施加的内存顺序制约 |
返回值
调用前被引用对象的值。