Namespaces
Variants

std::atomic_ref<T>:: fetch_and

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
仅当 T 为除 cv bool 之外的整数类型时提供
value_type fetch_and ( value_type arg,

std:: memory_order order =

std:: memory_order_seq_cst ) const noexcept ;
(C++20 起)

以原子方式将引用对象的当前值替换为原值与 arg 按位与操作的结果。此操作属于读-修改-写操作。内存受影响的情况根据 order 的值确定。

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

目录

参数

arg - 按位与运算的另一个参数
order - 强制执行的内存顺序约束

返回值

被引用对象的值,在此函数生效之前的值。

示例

缺陷报告

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

缺陷报告 适用范围 发布时行为 修正后行为
LWG 3508
( P3323R1 )
C++20 fetch_and const T 无意义 约束为仅接受非 const T