Namespaces
Variants

std::atomic_ref<T>:: operator=

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
value_type operator = ( value_type desired ) const noexcept ;
(1) (自 C++26 起为 constexpr)
atomic_ref & operator = ( const atomic_ref & ) = delete ;
(2)
1) 等价于 store ( desired ) ; return desired ; 。此重载仅当 std:: is_const_v < T > false 时参与重载决议。
2) atomic_ref 不具备 CopyAssignable 特性。

目录

参数

期望值 - 待赋值的数值

返回值

如上所述。

注释

与大多数赋值运算符不同, atomic_ref 的赋值运算符不会返回其左侧参数的引用,而是返回所存储值的副本。

缺陷报告

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

缺陷报告 适用范围 发布时的行为 正确行为
LWG 3508
( P3323R1 )
C++20 const T 的赋值运算符无意义 约束为仅接受非 const T

参见

构造 atomic_ref 对象
(公开成员函数)
以非原子参数原子地替换被引用对象的值
(公开成员函数)