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
T cv bool 以外の整数型である場合にのみ提供される
value_type operator & = ( value_type arg ) const noexcept ;
(1) (C++20以降)
value_type operator | = ( value_type arg ) const noexcept ;
(2) (C++20以降)
value_type operator ^ = ( value_type arg ) const noexcept ;
(3) (C++20以降)

参照先オブジェクトの現在値を、前回の値と arg を含む計算結果で原子的に置き換えます。これらの操作はread-modify-write操作です。

  • operator & = アトミックなビット単位ANDを実行します。 return fetch_and ( arg ) & arg ; と等価です。
  • operator ! = アトミックなビット単位ORを実行します。 return fetch_or ( arg ) | arg ; と等価です。
  • operator ^ = アトミックなビット単位XORを実行します。 return fetch_xor ( arg ) ^ arg ; と等価です。

これらのオーバーロードは、 std:: is_const_v < T > false の場合にのみ、オーバーロード解決に参加します。

目次

パラメータ

arg - 算術演算の引数

戻り値

結果の値(つまり、対応するメンバ関数の効果の直前に値に適用された対応する二項演算子の結果)。

注記

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

不具合報告

以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。

DR 適用対象 公開時の動作 正しい動作
LWG 3508
( P3323R1 )
C++20 複合代入演算子は const T に対して無意味であった 非constの T のみを受け入れるように制約

関連項目

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