Namespaces
Variants

std::atomic_ref<T>:: store

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
Safe reclamation
Hazard pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11) (deprecated in C++20)
(C++11) (deprecated in C++20)
Memory ordering
(C++11) (deprecated in C++26)
Free functions for atomic operations
Free functions for atomic flags
void store ( value_type desired,

std:: memory_order order =

std:: memory_order_seq_cst ) const noexcept ;
(自 C++26 起为 constexpr)

以原子操作将引用对象的当前值替换为 desired 。内存访问将根据 order 参数的值遵循相应的内存顺序约束。

此重载仅当 std:: is_const_v < T > false 时参与重载决议。

如果 order 不是 std:: memory_order_relaxed std:: memory_order_release std:: memory_order_seq_cst ,则行为未定义。

参数

desired - 要存储到引用对象中的值
order - 需要强制执行的内存顺序约束

缺陷报告

下列行为变更缺陷报告被追溯应用于先前发布的 C++ 标准。

DR 适用范围 发布时的行为 正确行为
LWG 3508
( P3323R1 )
C++20 store 对于 const T 无意义 约束为仅接受非 const T

参见

将值存储到由 atomic_ref 对象引用的目标对象中
(公开成员函数)