Namespaces
Variants

std::atomic<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
atomic< Integral > 特殊化のみのメンバー
T operator & = ( T arg ) noexcept ;
(1) (C++11以降)
T operator & = ( T arg ) volatile noexcept ;
(2) (C++11以降)
T operator | = ( T arg ) noexcept ;
(3) (C++11以降)
T operator | = ( T arg ) volatile noexcept ;
(4) (C++11以降)
T operator ^ = ( T arg ) noexcept ;
(5) (C++11以降)
T operator ^ = ( T arg ) volatile noexcept ;
(6) (C++11以降)

現在の値を、前の値と arg を含む演算結果で原子的に置き換えます。この操作は読み取り-修正-書き込み操作です。

  • operator & = アトミックなビット単位の論理積を実行します。次と等価です: return fetch_and ( arg ) & arg ;
  • operator | = アトミックなビット単位の論理和を実行します。次と等価です: return fetch_or ( arg ) | arg ;
  • operator ^ = アトミックなビット単位の排他的論理和を実行します。次と等価です: return fetch_xor ( arg ) ^ arg ;

std::atomic<T>::is_always_lock_free false であり、かつ任意の volatile オーバーロードがオーバーロード解決に参加する場合、非推奨となります。

(C++20以降)

目次

パラメータ

arg - 算術演算の引数

戻り値

結果の値(つまり、対応する二項演算子を、 * this 変更順序 において、対応するメンバー関数の効果の直前にあった値に適用した結果)。

注記

ほとんどの複合代入演算子とは異なり、アトミック型に対する複合代入演算子は左辺引数への参照を返しません。代わりに格納された値のコピーを返します。

関連項目

引数とアトミックオブジェクトの値との間でビット単位のANDをアトミックに実行し、以前に保持されていた値を取得する
(公開メンバ関数)
引数とアトミックオブジェクトの値との間でビット単位のORをアトミックに実行し、以前に保持されていた値を取得する
(公開メンバ関数)
引数とアトミックオブジェクトの値との間でビット単位のXORをアトミックに実行し、以前に保持されていた値を取得する
(公開メンバ関数)
アトミック値を1つインクリメントまたはデクリメントする
(公開メンバ関数)
アトミック値に加算または減算する
(公開メンバ関数)