Share via


atomic_fetch_sub 関数

atomic オブジェクトに格納されている既存の値から値を減算します。

template <class T> T* atomic_fetch_sub(
   volatile atomic<T*> *Atom,
   ptrdiff_t Value
) noexcept;

template <class T> T* atomic_fetch_sub(
   atomic<T*> *Atom,
   ptrdiff_t Value
) noexcept;

パラメーター

  • Atom
    T 型のポインターが格納された atomic オブジェクトへのポインター。

  • Value
    ptrdiff_t 型の値。

戻り値

操作の直前にアトミック オブジェクトによって格納されたポインター。

解説

atomic_fetch_sub 関数は、memory_order_seq_cst memory_order 制約を使用して、Atom に格納されている値から Value をアトミックに減算するために read-modify-write 操作を実行します。

アトミック型が atomic_address の場合、Value に ptrdiff_t 型があり、操作は char * として格納されているポインターを処理します。

この操作は、整数型に対してもオーバーロードします。

integral atomic_fetch_sub(
    volatile atomic-integral * Atom, integral Value
) noexcept;

integral atomic_fetch_sub(
    atomic-integral * Atom, integral Value
) noexcept;

必要条件

ヘッダー: atomic

名前空間: std

参照

関連項目

<atomic>

atomic 構造体

atomic_fetch_sub_explicit 関数