Namespaces
Variants
Views
Actions

std::atomic_fetch_and, std::atomic_fetch_and_explicit

From cppreference.com
Defined in header <atomic>
template< class Integral >
Integral atomic_fetch_and( std::atomic<Integral>* obj, Integral arg );
(1) (since C++11)
template< class Integral >
Integral atomic_fetch_and( volatile std::atomic<Integral>* obj, Integral arg );
(2) (since C++11)
template< class Integral >

Integral atomic_fetch_and_explicit( std::atomic<Integral>* obj, Integral arg,

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

Integral atomic_fetch_and_explicit( volatile std::atomic<Integral>* obj, Integral arg,

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

1-2) Atomically replaces the value pointed by arg with the result of bitwise AND between the old value of obj and arg, and returns the value obj held previously, as if by obj->fetch_and(arg)

3-4) Atomically replaces the value pointed by arg with the result of bitwise AND between the old value of obj and arg, and returns the value obj held previously, as if by obj->fetch_and(arg, order)

Contents

[edit] Parameters

obj - pointer to the atomic object to modify
arg - the value to bitwise AND to the value stored in the atomic object
order - the memory sycnhronization ordering for this operation: all values are permitted.

[edit] Return value

The value held previously by the atomic object pointed to by obj

[edit] Exceptions

noexcept specification:  
noexcept
  (since C++11)

[edit] Possible implementation

[edit] Example

[edit] See also

(C++11)
atomically performs bitwise AND between the argument and the value of the atomic object and obtains the value held previously
(public member function of std::atomic) [edit]
replaces the atomic object with the result of logical OR with a non-atomic argument and obtains the previous value of the atomic
(function template) [edit]
replaces the atomic object with the result of logical XOR with a non-atomic argument and obtains the previous value of the atomic
(function template) [edit]