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

std::atomic::operators (int)

T operator++(); T operator++() volatile;

(1)

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

T* operator++(); T* operator++() volatile;

(1)

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

T operator++( int ); T operator++( int ) volatile;

(2)

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

T* operator++( int ); T* operator++( int ) volatile;

(2)

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

T operator--(); T operator--() volatile;

(3)

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

T* operator--(); T* operator--() volatile;

(3)

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

T operator--( int ); T operator--( int ) volatile;

(4)

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

T* operator--( int ); T* operator--( int ) volatile;

(4)

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

以原子方式增加或减少当前值。操作是读-修改-写操作.

1%29执行原子前增量.。相当于fetch_add(1)+1...

2%29执行原子后增量.。相当于fetch_add(1)...

3%29执行原子预减量.。相当于fetch_sub(1)-1

4%29执行原子后减量.。相当于fetch_sub(1)...

签名Integral类型,算法定义为使用两种补码表示形式。没有未定义的结果。为T*类型,结果可能是一个未定义的地址,但否则操作就没有未定义的行为。

参数

%280%29

返回值

修改后原子变量的值为1,3%29。形式上,在紧接此函数的效果之前的修改顺序成*this...

修改前原子变量的值为2,4%,29。形式上,此函数的效果之前的值在修改顺序成*this...

例外

noexcept规格:

noexcept

注记

与大多数预增量和预减量操作符不同,原子类型的预增量和预减量运算符不返回对修改对象的引用。它们返回存储值的副本。

另见

fetch_add

atomically adds the argument to the value stored in the atomic object and obtains the value held previously (public member function)

fetch_sub

atomically subtracts the argument from the value stored in the atomic object and obtains the value held previously (public member function)

operator+=operator-=operator&=operator|=operator^=

adds, subtracts, or performs bitwise AND, OR, XOR with the atomic value (public member function)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com