Namespaces
Variants
Actions

std::atomic_fetch_sub, std::atomic_fetch_sub_explicit

From cppreference.com
< cpp‎ | atomic
 
 
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
(C++11)
Generic lock management
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
(C++11)
Safe reclamation
(C++26)
Hazard pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11)(deprecated in C++20)
(C++11)(deprecated in C++20)
Memory ordering
(C++11)(deprecated in C++26)
Free functions for atomic operations
atomic_fetch_subatomic_fetch_sub_explicit
(C++11)(C++11)
Free functions for atomic flags
 
Defined in header <atomic>
template< class T >

T atomic_fetch_sub( std::atomic<T>* obj,

                    typename std::atomic<T>::difference_type arg ) noexcept;
(1) (since C++11)
template< class T >

T atomic_fetch_sub( volatile std::atomic<T>* obj,

                    typename std::atomic<T>::difference_type arg ) noexcept;
(2) (since C++11)
template< class T >

T atomic_fetch_sub_explicit( std::atomic<T>* obj,
                             typename std::atomic<T>::difference_type arg,

                             std::memory_order order ) noexcept;
(3) (since C++11)
template< class T >

T atomic_fetch_sub_explicit( volatile std::atomic<T>* obj,
                             typename std::atomic<T>::difference_type arg,

                             std::memory_order order ) noexcept;
(4) (since C++11)

Performs atomic subtraction. Atomically subtracts arg from the value pointed to by obj and returns the value obj held previously. The operation is performed as if the following was executed:

1,2) obj->fetch_sub(arg)
3,4) obj->fetch_sub(arg, order)

If std::atomic<T> has no fetch_sub member (this member is only provided for integral, floating-point(since C++20) and pointer types except bool), the program is ill-formed.

Contents