public member function
<atomic>
std::atomic::fetch_sub
如果 T 是整數型別 (1) | T fetch_sub (T val, memory_order sync = memory_order_seq_cst) volatile noexcept;T fetch_sub (T val, memory_order sync = memory_order_seq_cst) noexcept; |
---|
如果 T 是指標型別 (2) | T fetch_sub (ptrdiff_t val, memory_order sync = memory_order_seq_cst) volatile noexcept;T fetch_sub (ptrdiff_t val, memory_order sync = memory_order_seq_cst) noexcept; |
---|
Subtract from contained value
Subtracts val from the contained value and returns the value it had immediately before the operation.
整個操作是原子的(一個原子讀-修改-寫操作):在函式讀取(並返回)其值到修改其值的時刻之間,該值不會受到其他執行緒的影響。
This member function is only defined in the atomic specializations for integral (1) and pointer (2) types (except for bool
).
If the default value is used for the second argument, this function is equivalent to atomic::operator-=.
返回值
呼叫前的儲存值。
T 是 atomic 的模板引數(包含值的型別)。
資料競爭
無資料競爭(原子操作)。記憶體順序由引數 sync 指定。