std::atomic_ref<T>:: operator&=,|=,^=
From cppreference.net
<
cpp
|
atomic
|
atomic ref
C++
Concurrency support library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::atomic_ref
| Member functions | ||||
|
(C++26)
|
||||
|
Operations for arithmetic types
(except
bool
and pointer-to-object)
|
||||
|
Operations for integral types
(except
bool
and pointer-to-object)
|
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
|
Operations for integral types
(except
bool
)
|
||||
|
atomic_ref::operator&=
atomic_ref::operator|=
atomic_ref::operator^=
|
||||
| Constants | ||||
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) |