Namespaces
Variants

std:: atomic_fetch_max, std:: atomic_fetch_max_explicit

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
atomic_fetch_max atomic_fetch_max_explicit
(C++26) (C++26)
Free functions for atomic flags
ヘッダーで定義 <atomic>
template < class T >

T atomic_fetch_max ( std:: atomic < T > * obj,

typename std:: atomic < T > :: value_type arg ) noexcept ;
(1) (C++26以降)
template < class T >

T atomic_fetch_max ( volatile std:: atomic < T > * obj,

typename std:: atomic < T > :: value_type arg ) noexcept ;
(2) (C++26以降)
template < class T >

T atomic_fetch_max_explicit ( std:: atomic < T > * obj,
typename std:: atomic < T > :: value_type arg,

std:: memory_order order ) noexcept ;
(3) (C++26以降)
template < class T >

T atomic_fetch_max_explicit ( volatile std:: atomic < T > * obj,
typename std:: atomic < T > :: value_type arg,

std:: memory_order order ) noexcept ;
(4) (C++26以降)

obj が指す値を、 obj の旧値と arg の間の std::max の結果でアトミックに置き換えます。 obj が以前保持していた値を返します。この操作は以下のコードが実行されたかのように行われます:

1,2) obj - > fetch_max ( arg )
3,4) obj - > fetch_max ( arg, order )

std::atomic<T> fetch_max メンバが存在しない場合(このメンバは 整数型 および ポインタ型 に対してのみ提供され、 bool を除く)、プログラムは不適格となります。

目次

パラメータ

obj - 変更対象のアトミックオブジェクトへのポインタ
arg - アトミックオブジェクトに格納された値と std::max を取る値
order - メモリ同期順序

戻り値

この関数の効果が適用される直前の値、 modification order における * obj の値。

注記

機能テスト マクロ 標準 機能
__cpp_lib_atomic_min_max 202403L (C++26) アトミック最小値/最大値

関連項目

(C++26)
引数とアトミックオブジェクトの値の間で std::max をアトミックに実行し、以前に保持されていた値を取得する
( std::atomic<T> の公開メンバ関数)
アトミックオブジェクトを非アトミックな引数との std::min の結果で置き換え、アトミックオブジェクトの以前の値を取得する
(関数テンプレート)