std::atomic<T>:: operator&=,|=,^=
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
| Constants | ||||
|
(C++17)
|
||||
| Specialized member functions | ||||
|
Specialized for integral,
floating-point (C++20) and pointer types |
||||
|
Specialized for integral and
pointer types only |
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
| Specialized for integral types only | ||||
|
atomic::operator&=
atomic::operator|=
atomic::operator^=
|
|
仅属于
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 重载参与重载决议时,该用法被弃用。 |
(since C++20) |
目录 |
参数
| arg | - | 算术运算的参数 |
返回值
结果值(即对 * this 的 修改顺序 中对应成员函数生效前的值应用相应二元运算符所得的结果)。
注释
与大多数复合赋值运算符不同,原子类型的复合赋值运算符不会返回其左操作数的引用,而是返回存储值的副本。
参见
|
以原子方式执行参数与原子对象值的按位与操作,并获取先前持有的值
(公开成员函数) |
|
|
以原子方式执行参数与原子对象值的按位或操作,并获取先前持有的值
(公开成员函数) |
|
|
以原子方式执行参数与原子对象值的按位异或操作,并获取先前持有的值
(公开成员函数) |
|
|
将原子值递增或递减一
(公开成员函数) |
|
|
对原子值进行加法或减法运算
(公开成员函数) |