[atomics.syn]

# 32 Concurrency support library [[thread]](./#thread)

## 32.5 Atomic operations [[atomics]](atomics#syn)

### 32.5.2 Header <atomic> synopsis [atomics.syn]

[ð](#header:%3catomic%3e)

namespace std {// [[atomics.order]](atomics.order "32.5.4 Order and consistency"), order and consistencyenum class memory_order : *unspecified*; // freestandinginline constexpr memory_order memory_order_relaxed = memory_order::relaxed; // freestandinginline constexpr memory_order memory_order_acquire = memory_order::acquire; // freestandinginline constexpr memory_order memory_order_release = memory_order::release; // freestandinginline constexpr memory_order memory_order_acq_rel = memory_order::acq_rel; // freestandinginline constexpr memory_order memory_order_seq_cst = memory_order::seq_cst; // freestanding}// [[atomics.lockfree]](atomics.lockfree "32.5.5 Lock-free property"), lock-free property#define ATOMIC_BOOL_LOCK_FREE *unspecified* // freestanding#define ATOMIC_CHAR_LOCK_FREE *unspecified* // freestanding#define ATOMIC_CHAR8_T_LOCK_FREE *unspecified* // freestanding#define ATOMIC_CHAR16_T_LOCK_FREE *unspecified* // freestanding#define ATOMIC_CHAR32_T_LOCK_FREE *unspecified* // freestanding#define ATOMIC_WCHAR_T_LOCK_FREE *unspecified* // freestanding#define ATOMIC_SHORT_LOCK_FREE *unspecified* // freestanding#define ATOMIC_INT_LOCK_FREE *unspecified* // freestanding#define ATOMIC_LONG_LOCK_FREE *unspecified* // freestanding#define ATOMIC_LLONG_LOCK_FREE *unspecified* // freestanding#define ATOMIC_POINTER_LOCK_FREE *unspecified* // freestandingnamespace std {// [[atomics.ref.generic]](atomics.ref.generic "32.5.7 Class template atomic_­ref"), class template atomic_reftemplate<class T> struct atomic_ref; // freestanding// [[atomics.types.generic]](atomics.types.generic "32.5.8 Class template atomic"), class template atomictemplate<class T> struct atomic; // freestanding// [[atomics.types.pointer]](atomics.types.pointer "32.5.8.5 Partial specialization for pointers"), partial specialization for pointerstemplate<class T> struct atomic<T*>; // freestanding// [[atomics.nonmembers]](atomics.nonmembers "32.5.9 Non-member functions"), non-member functionstemplate<class T>bool atomic_is_lock_free(const volatile atomic<T>*) noexcept; // freestandingtemplate<class T>bool atomic_is_lock_free(const atomic<T>*) noexcept; // freestandingtemplate<class T>void atomic_store(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr void atomic_store(atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>void atomic_store_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type, memory_order) noexcept; template<class T>constexpr void atomic_store_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type, memory_order) noexcept; template<class T> T atomic_load(const volatile atomic<T>*) noexcept; // freestandingtemplate<class T>constexpr T atomic_load(const atomic<T>*) noexcept; // freestandingtemplate<class T> T atomic_load_explicit(const volatile atomic<T>*, memory_order) noexcept; // freestandingtemplate<class T>constexpr T atomic_load_explicit(const atomic<T>*, memory_order) noexcept; // freestandingtemplate<class T> T atomic_exchange(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr T atomic_exchange(atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T> T atomic_exchange_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type, memory_order) noexcept; template<class T>constexpr T atomic_exchange_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>bool atomic_compare_exchange_weak(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type*, typename atomic<T>::value_type) noexcept; template<class T>constexpr bool atomic_compare_exchange_weak(atomic<T>*, // freestandingtypename atomic<T>::value_type*, typename atomic<T>::value_type) noexcept; template<class T>bool atomic_compare_exchange_strong(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type*, typename atomic<T>::value_type) noexcept; template<class T>constexpr bool atomic_compare_exchange_strong(atomic<T>*, // freestandingtypename atomic<T>::value_type*, typename atomic<T>::value_type) noexcept; template<class T>bool atomic_compare_exchange_weak_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type*, typename atomic<T>::value_type,
 memory_order, memory_order) noexcept; template<class T>constexpr bool atomic_compare_exchange_weak_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type*, typename atomic<T>::value_type,
 memory_order, memory_order) noexcept; template<class T>bool atomic_compare_exchange_strong_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type*, typename atomic<T>::value_type,
 memory_order, memory_order) noexcept; template<class T>constexpr bool atomic_compare_exchange_strong_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type*, typename atomic<T>::value_type,
 memory_order, memory_order) noexcept; template<class T> T atomic_fetch_add(volatile atomic<T>*, // freestandingtypename atomic<T>::difference_type) noexcept; template<class T>constexpr T atomic_fetch_add(atomic<T>*, // freestandingtypename atomic<T>::difference_type) noexcept; template<class T> T atomic_fetch_add_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::difference_type,
 memory_order) noexcept; template<class T>constexpr T atomic_fetch_add_explicit(atomic<T>*, // freestandingtypename atomic<T>::difference_type,
 memory_order) noexcept; template<class T> T atomic_fetch_sub(volatile atomic<T>*, // freestandingtypename atomic<T>::difference_type) noexcept; template<class T>constexpr T atomic_fetch_sub(atomic<T>*, // freestandingtypename atomic<T>::difference_type) noexcept; template<class T> T atomic_fetch_sub_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::difference_type,
 memory_order) noexcept; template<class T>constexpr T atomic_fetch_sub_explicit(atomic<T>*, // freestandingtypename atomic<T>::difference_type,
 memory_order) noexcept; template<class T> T atomic_fetch_and(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr T atomic_fetch_and(atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T> T atomic_fetch_and_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>constexpr T atomic_fetch_and_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T> T atomic_fetch_or(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr T atomic_fetch_or(atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T> T atomic_fetch_or_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>constexpr T atomic_fetch_or_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T> T atomic_fetch_xor(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr T atomic_fetch_xor(atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T> T atomic_fetch_xor_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>constexpr T atomic_fetch_xor_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T> T atomic_fetch_max(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr T atomic_fetch_max(atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T> T atomic_fetch_max_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>constexpr T atomic_fetch_max_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T> T atomic_fetch_min(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr T atomic_fetch_min(atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T> T atomic_fetch_min_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>constexpr T atomic_fetch_min_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>void atomic_store_add(volatile atomic<T>*, // freestandingtypename atomic<T>::difference_type) noexcept; template<class T>constexpr void atomic_store_add(atomic<T>*, // freestandingtypename atomic<T>::difference_type) noexcept; template<class T>void atomic_store_add_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::difference_type, memory_order) noexcept; template<class T>constexpr void atomic_store_add_explicit(atomic<T>*, // freestandingtypename atomic<T>::difference_type,
 memory_order) noexcept; template<class T>void atomic_store_sub(volatile atomic<T>*, // freestandingtypename atomic<T>::difference_type) noexcept; template<class T>constexpr void atomic_store_sub(atomic<T>*, // freestandingtypename atomic<T>::difference_type) noexcept; template<class T>void atomic_store_sub_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::difference_type, memory_order) noexcept; template<class T>constexpr void atomic_store_sub_explicit(atomic<T>*, // freestandingtypename atomic<T>::difference_type,
 memory_order) noexcept; template<class T>void atomic_store_and(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr void atomic_store_and(atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>void atomic_store_and_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type, memory_order) noexcept; template<class T>constexpr void atomic_store_and_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>void atomic_store_or(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr void atomic_store_or(atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>void atomic_store_or_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type, memory_order) noexcept; template<class T>constexpr void atomic_store_or_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>void atomic_store_xor(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr void atomic_store_xor(atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>void atomic_store_xor_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type, memory_order) noexcept; template<class T>constexpr void atomic_store_xor_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>void atomic_store_max(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr void atomic_store_max(atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>void atomic_store_max_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type, memory_order) noexcept; template<class T>constexpr void atomic_store_max_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>void atomic_store_min(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr void atomic_store_min(atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>void atomic_store_min_explicit(volatile atomic<T>*, // freestandingtypename atomic<T>::value_type, memory_order) noexcept; template<class T>constexpr void atomic_store_min_explicit(atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>void atomic_wait(const volatile atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>constexpr void atomic_wait(const atomic<T>*, // freestandingtypename atomic<T>::value_type) noexcept; template<class T>void atomic_wait_explicit(const volatile atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>constexpr void atomic_wait_explicit(const atomic<T>*, // freestandingtypename atomic<T>::value_type,
 memory_order) noexcept; template<class T>void atomic_notify_one(volatile atomic<T>*) noexcept; // freestandingtemplate<class T>constexpr void atomic_notify_one(atomic<T>*) noexcept; // freestandingtemplate<class T>void atomic_notify_all(volatile atomic<T>*) noexcept; // freestandingtemplate<class T>constexpr void atomic_notify_all(atomic<T>*) noexcept; // freestanding// [[atomics.alias]](atomics.alias "32.5.3 Type aliases"), type aliasesusing atomic_bool = atomic<bool>; // freestandingusing atomic_char = atomic<char>; // freestandingusing atomic_schar = atomic<signed char>; // freestandingusing atomic_uchar = atomic<unsigned char>; // freestandingusing atomic_short = atomic<short>; // freestandingusing atomic_ushort = atomic<unsigned short>; // freestandingusing atomic_int = atomic<int>; // freestandingusing atomic_uint = atomic<unsigned int>; // freestandingusing atomic_long = atomic<long>; // freestandingusing atomic_ulong = atomic<unsigned long>; // freestandingusing atomic_llong = atomic<long long>; // freestandingusing atomic_ullong = atomic<unsigned long long>; // freestandingusing atomic_char8_t = atomic<char8_t>; // freestandingusing atomic_char16_t = atomic<char16_t>; // freestandingusing atomic_char32_t = atomic<char32_t>; // freestandingusing atomic_wchar_t = atomic<wchar_t>; // freestandingusing atomic_int8_t = atomic<int8_t>; // freestandingusing atomic_uint8_t = atomic<uint8_t>; // freestandingusing atomic_int16_t = atomic<int16_t>; // freestandingusing atomic_uint16_t = atomic<uint16_t>; // freestandingusing atomic_int32_t = atomic<int32_t>; // freestandingusing atomic_uint32_t = atomic<uint32_t>; // freestandingusing atomic_int64_t = atomic<int64_t>; // freestandingusing atomic_uint64_t = atomic<uint64_t>; // freestandingusing atomic_int_least8_t = atomic<int_least8_t>; // freestandingusing atomic_uint_least8_t = atomic<uint_least8_t>; // freestandingusing atomic_int_least16_t = atomic<int_least16_t>; // freestandingusing atomic_uint_least16_t = atomic<uint_least16_t>; // freestandingusing atomic_int_least32_t = atomic<int_least32_t>; // freestandingusing atomic_uint_least32_t = atomic<uint_least32_t>; // freestandingusing atomic_int_least64_t = atomic<int_least64_t>; // freestandingusing atomic_uint_least64_t = atomic<uint_least64_t>; // freestandingusing atomic_int_fast8_t = atomic<int_fast8_t>; // freestandingusing atomic_uint_fast8_t = atomic<uint_fast8_t>; // freestandingusing atomic_int_fast16_t = atomic<int_fast16_t>; // freestandingusing atomic_uint_fast16_t = atomic<uint_fast16_t>; // freestandingusing atomic_int_fast32_t = atomic<int_fast32_t>; // freestandingusing atomic_uint_fast32_t = atomic<uint_fast32_t>; // freestandingusing atomic_int_fast64_t = atomic<int_fast64_t>; // freestandingusing atomic_uint_fast64_t = atomic<uint_fast64_t>; // freestandingusing atomic_intptr_t = atomic<intptr_t>; // freestandingusing atomic_uintptr_t = atomic<uintptr_t>; // freestandingusing atomic_size_t = atomic<size_t>; // freestandingusing atomic_ptrdiff_t = atomic<ptrdiff_t>; // freestandingusing atomic_intmax_t = atomic<intmax_t>; // freestandingusing atomic_uintmax_t = atomic<uintmax_t>; // freestandingusing atomic_signed_lock_free = *see below*; using atomic_unsigned_lock_free = *see below*; // [[atomics.flag]](atomics.flag "32.5.10 Flag type and operations"), flag type and operationsstruct atomic_flag; // freestandingbool atomic_flag_test(const volatile atomic_flag*) noexcept; // freestandingconstexpr bool atomic_flag_test(const atomic_flag*) noexcept; // freestandingbool atomic_flag_test_explicit(const volatile atomic_flag*, // freestanding memory_order) noexcept; constexpr bool atomic_flag_test_explicit(const atomic_flag*, // freestanding memory_order) noexcept; bool atomic_flag_test_and_set(volatile atomic_flag*) noexcept; // freestandingconstexpr bool atomic_flag_test_and_set(atomic_flag*) noexcept; // freestandingbool atomic_flag_test_and_set_explicit(volatile atomic_flag*, // freestanding memory_order) noexcept; constexpr bool atomic_flag_test_and_set_explicit(atomic_flag*, // freestanding memory_order) noexcept; void atomic_flag_clear(volatile atomic_flag*) noexcept; // freestandingconstexpr void atomic_flag_clear(atomic_flag*) noexcept; // freestandingvoid atomic_flag_clear_explicit(volatile atomic_flag*, memory_order) noexcept; // freestandingconstexpr void atomic_flag_clear_explicit(atomic_flag*, memory_order) noexcept; // freestandingvoid atomic_flag_wait(const volatile atomic_flag*, bool) noexcept; // freestandingconstexpr void atomic_flag_wait(const atomic_flag*, bool) noexcept; // freestandingvoid atomic_flag_wait_explicit(const volatile atomic_flag*, // freestandingbool, memory_order) noexcept; constexpr void atomic_flag_wait_explicit(const atomic_flag*, // freestandingbool, memory_order) noexcept; void atomic_flag_notify_one(volatile atomic_flag*) noexcept; // freestandingconstexpr void atomic_flag_notify_one(atomic_flag*) noexcept; // freestandingvoid atomic_flag_notify_all(volatile atomic_flag*) noexcept; // freestandingconstexpr void atomic_flag_notify_all(atomic_flag*) noexcept; // freestanding#define ATOMIC_FLAG_INIT *see below* // freestanding// [[atomics.fences]](atomics.fences "32.5.11 Fences"), fencesextern "C" constexpr void atomic_thread_fence(memory_order) noexcept; // freestandingextern "C" constexpr void atomic_signal_fence(memory_order) noexcept; // freestanding}
