std::atomic::operators
:原子::运算符+=,-=,&=,=,^=
| (1) | (since C++11) (member only of atomic |
---|---|---|
T operator+=( T arg | | |
T operator+=( T arg ) volatile; | | |
| (1) | (since C++11) (member only of atomic<T*> template specialization) |
T* operator+=( std::ptrdiff_t arg | | |
T* operator+=( std::ptrdiff_t arg ) volatile; | | |
| (2) | (since C++11) (member only of atomic<Integral> template specialization) |
T operator-=( T arg | | |
T operator-=( T arg ) volatile; | | |
| (2) | (since C++11) (member only of atomic<T*> template specialization) |
T* operator-=( std::ptrdiff_t arg | | |
T* operator-=( std::ptrdiff_t arg ) volatile; | | |
| (3) | (since C++11) (member only of atomic<Integral> template specialization) |
T operator&=( T arg | | |
T operator&=( T arg ) volatile; | | |
| (4) | (since C++11) (member only of atomic<Integral> template specialization) |
T operator|=( T arg | | |
T operator|=( T arg ) volatile; | | |
| (5) | (since C++11) (member only of atomic<Integral> template specialization) |
T operator^=( T arg | | |
T operator^=( T arg ) volatile; | |
原子化地用涉及到前一个值的计算结果替换当前值arg
.操作是读-修改-写操作.
1%29执行原子加法。相当于fetch_add(arg)
+Arg.
2%29执行原子减法。相当于fetch_sub(arg)
-Arg
3%29按位执行原子运算。相当于fetch_and(arg)
&Arg.
4%29按位执行原子运算。相当于fetch_or(arg)
阿格。
5%29执行原子位排他性或。相当于fetch_xor(arg)
^Arg
签名Integral
类型,算法定义为使用两种补码表示形式。没有未定义的结果。为T*
类型,结果可能是一个未定义的地址,但否则操作就没有未定义的行为。
参数
arg | - | the argument for the arithmetic operation |
---|
返回值
结果值%28,即将相应的二进制运算符应用于紧接在修改顺序成*this
29%。
例外
noexcept
规格:
noexcept
注记
与大多数复合赋值运算符不同,原子类型的复合赋值运算符不返回对其左侧参数的引用。它们返回存储值的副本。
另见
operator++operator++(int)operator--operator--(int) | increments or decrements the atomic value by one (public member function) |
---|
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。