首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::atomic::operators

(1)

(since C++11) (member only of atomic<Integral> template specialization)

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,即将相应的二进制运算符应用于紧接在修改顺序成*this29%。

例外

noexcept规格:

noexcept

注记

与大多数复合赋值运算符不同,原子类型的复合赋值运算符不返回对其左侧参数的引用。它们返回存储值的副本。

另见

operator++operator++(int)operator--operator--(int)

increments or decrements the atomic value by one (public member function)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券