Namespaces
Variants

std::atomic_ref<T>:: fetch_max

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_max ( value_type arg,

std:: memory_order order =

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

以原子操作将引用对象的当前值替换为原值与 arg std::max 计算后的结果。即执行原子最大值操作。该操作属于读-修改-写操作。内存影响根据 order 的值确定。

如果 T 是指针类型且指针指向不同的完整对象(或其子对象), 指针比较 无法建立 严格弱序 关系。

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

目录

参数

arg - std::max 的另一个参数
order - 要强制执行的内存顺序约束

返回值

* this 修改顺序 中,此函数生效前紧邻的值。

注释

功能测试 标准 功能
__cpp_lib_atomic_min_max 202403L (C++26) 原子最小值/最大值

示例