[atomics.syn] # 32 Concurrency support library [[thread]](./#thread) ## 32.5 Atomic operations [[atomics]](atomics#syn) ### 32.5.2 Header 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 struct atomic_ref; // freestanding// [[atomics.types.generic]](atomics.types.generic "32.5.8 Class template atomic"), class template atomictemplate struct atomic; // freestanding// [[atomics.types.pointer]](atomics.types.pointer "32.5.8.5 Partial specialization for pointers"), partial specialization for pointerstemplate struct atomic; // freestanding// [[atomics.nonmembers]](atomics.nonmembers "32.5.9 Non-member functions"), non-member functionstemplatebool atomic_is_lock_free(const volatile atomic*) noexcept; // freestandingtemplatebool atomic_is_lock_free(const atomic*) noexcept; // freestandingtemplatevoid atomic_store(volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr void atomic_store(atomic*, // freestandingtypename atomic::value_type) noexcept; templatevoid atomic_store_explicit(volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr void atomic_store_explicit(atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; template T atomic_load(const volatile atomic*) noexcept; // freestandingtemplateconstexpr T atomic_load(const atomic*) noexcept; // freestandingtemplate T atomic_load_explicit(const volatile atomic*, memory_order) noexcept; // freestandingtemplateconstexpr T atomic_load_explicit(const atomic*, memory_order) noexcept; // freestandingtemplate T atomic_exchange(volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr T atomic_exchange(atomic*, // freestandingtypename atomic::value_type) noexcept; template T atomic_exchange_explicit(volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr T atomic_exchange_explicit(atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templatebool atomic_compare_exchange_weak(volatile atomic*, // freestandingtypename atomic::value_type*, typename atomic::value_type) noexcept; templateconstexpr bool atomic_compare_exchange_weak(atomic*, // freestandingtypename atomic::value_type*, typename atomic::value_type) noexcept; templatebool atomic_compare_exchange_strong(volatile atomic*, // freestandingtypename atomic::value_type*, typename atomic::value_type) noexcept; templateconstexpr bool atomic_compare_exchange_strong(atomic*, // freestandingtypename atomic::value_type*, typename atomic::value_type) noexcept; templatebool atomic_compare_exchange_weak_explicit(volatile atomic*, // freestandingtypename atomic::value_type*, typename atomic::value_type, memory_order, memory_order) noexcept; templateconstexpr bool atomic_compare_exchange_weak_explicit(atomic*, // freestandingtypename atomic::value_type*, typename atomic::value_type, memory_order, memory_order) noexcept; templatebool atomic_compare_exchange_strong_explicit(volatile atomic*, // freestandingtypename atomic::value_type*, typename atomic::value_type, memory_order, memory_order) noexcept; templateconstexpr bool atomic_compare_exchange_strong_explicit(atomic*, // freestandingtypename atomic::value_type*, typename atomic::value_type, memory_order, memory_order) noexcept; template T atomic_fetch_add(volatile atomic*, // freestandingtypename atomic::difference_type) noexcept; templateconstexpr T atomic_fetch_add(atomic*, // freestandingtypename atomic::difference_type) noexcept; template T atomic_fetch_add_explicit(volatile atomic*, // freestandingtypename atomic::difference_type, memory_order) noexcept; templateconstexpr T atomic_fetch_add_explicit(atomic*, // freestandingtypename atomic::difference_type, memory_order) noexcept; template T atomic_fetch_sub(volatile atomic*, // freestandingtypename atomic::difference_type) noexcept; templateconstexpr T atomic_fetch_sub(atomic*, // freestandingtypename atomic::difference_type) noexcept; template T atomic_fetch_sub_explicit(volatile atomic*, // freestandingtypename atomic::difference_type, memory_order) noexcept; templateconstexpr T atomic_fetch_sub_explicit(atomic*, // freestandingtypename atomic::difference_type, memory_order) noexcept; template T atomic_fetch_and(volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr T atomic_fetch_and(atomic*, // freestandingtypename atomic::value_type) noexcept; template T atomic_fetch_and_explicit(volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr T atomic_fetch_and_explicit(atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; template T atomic_fetch_or(volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr T atomic_fetch_or(atomic*, // freestandingtypename atomic::value_type) noexcept; template T atomic_fetch_or_explicit(volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr T atomic_fetch_or_explicit(atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; template T atomic_fetch_xor(volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr T atomic_fetch_xor(atomic*, // freestandingtypename atomic::value_type) noexcept; template T atomic_fetch_xor_explicit(volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr T atomic_fetch_xor_explicit(atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; template T atomic_fetch_max(volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr T atomic_fetch_max(atomic*, // freestandingtypename atomic::value_type) noexcept; template T atomic_fetch_max_explicit(volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr T atomic_fetch_max_explicit(atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; template T atomic_fetch_min(volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr T atomic_fetch_min(atomic*, // freestandingtypename atomic::value_type) noexcept; template T atomic_fetch_min_explicit(volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr T atomic_fetch_min_explicit(atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templatevoid atomic_store_add(volatile atomic*, // freestandingtypename atomic::difference_type) noexcept; templateconstexpr void atomic_store_add(atomic*, // freestandingtypename atomic::difference_type) noexcept; templatevoid atomic_store_add_explicit(volatile atomic*, // freestandingtypename atomic::difference_type, memory_order) noexcept; templateconstexpr void atomic_store_add_explicit(atomic*, // freestandingtypename atomic::difference_type, memory_order) noexcept; templatevoid atomic_store_sub(volatile atomic*, // freestandingtypename atomic::difference_type) noexcept; templateconstexpr void atomic_store_sub(atomic*, // freestandingtypename atomic::difference_type) noexcept; templatevoid atomic_store_sub_explicit(volatile atomic*, // freestandingtypename atomic::difference_type, memory_order) noexcept; templateconstexpr void atomic_store_sub_explicit(atomic*, // freestandingtypename atomic::difference_type, memory_order) noexcept; templatevoid atomic_store_and(volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr void atomic_store_and(atomic*, // freestandingtypename atomic::value_type) noexcept; templatevoid atomic_store_and_explicit(volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr void atomic_store_and_explicit(atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templatevoid atomic_store_or(volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr void atomic_store_or(atomic*, // freestandingtypename atomic::value_type) noexcept; templatevoid atomic_store_or_explicit(volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr void atomic_store_or_explicit(atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templatevoid atomic_store_xor(volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr void atomic_store_xor(atomic*, // freestandingtypename atomic::value_type) noexcept; templatevoid atomic_store_xor_explicit(volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr void atomic_store_xor_explicit(atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templatevoid atomic_store_max(volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr void atomic_store_max(atomic*, // freestandingtypename atomic::value_type) noexcept; templatevoid atomic_store_max_explicit(volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr void atomic_store_max_explicit(atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templatevoid atomic_store_min(volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr void atomic_store_min(atomic*, // freestandingtypename atomic::value_type) noexcept; templatevoid atomic_store_min_explicit(volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr void atomic_store_min_explicit(atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templatevoid atomic_wait(const volatile atomic*, // freestandingtypename atomic::value_type) noexcept; templateconstexpr void atomic_wait(const atomic*, // freestandingtypename atomic::value_type) noexcept; templatevoid atomic_wait_explicit(const volatile atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templateconstexpr void atomic_wait_explicit(const atomic*, // freestandingtypename atomic::value_type, memory_order) noexcept; templatevoid atomic_notify_one(volatile atomic*) noexcept; // freestandingtemplateconstexpr void atomic_notify_one(atomic*) noexcept; // freestandingtemplatevoid atomic_notify_all(volatile atomic*) noexcept; // freestandingtemplateconstexpr void atomic_notify_all(atomic*) noexcept; // freestanding// [[atomics.alias]](atomics.alias "32.5.3 Type aliases"), type aliasesusing atomic_bool = atomic; // freestandingusing atomic_char = atomic; // freestandingusing atomic_schar = atomic; // freestandingusing atomic_uchar = atomic; // freestandingusing atomic_short = atomic; // freestandingusing atomic_ushort = atomic; // freestandingusing atomic_int = atomic; // freestandingusing atomic_uint = atomic; // freestandingusing atomic_long = atomic; // freestandingusing atomic_ulong = atomic; // freestandingusing atomic_llong = atomic; // freestandingusing atomic_ullong = atomic; // freestandingusing atomic_char8_t = atomic; // freestandingusing atomic_char16_t = atomic; // freestandingusing atomic_char32_t = atomic; // freestandingusing atomic_wchar_t = atomic; // freestandingusing atomic_int8_t = atomic; // freestandingusing atomic_uint8_t = atomic; // freestandingusing atomic_int16_t = atomic; // freestandingusing atomic_uint16_t = atomic; // freestandingusing atomic_int32_t = atomic; // freestandingusing atomic_uint32_t = atomic; // freestandingusing atomic_int64_t = atomic; // freestandingusing atomic_uint64_t = atomic; // freestandingusing atomic_int_least8_t = atomic; // freestandingusing atomic_uint_least8_t = atomic; // freestandingusing atomic_int_least16_t = atomic; // freestandingusing atomic_uint_least16_t = atomic; // freestandingusing atomic_int_least32_t = atomic; // freestandingusing atomic_uint_least32_t = atomic; // freestandingusing atomic_int_least64_t = atomic; // freestandingusing atomic_uint_least64_t = atomic; // freestandingusing atomic_int_fast8_t = atomic; // freestandingusing atomic_uint_fast8_t = atomic; // freestandingusing atomic_int_fast16_t = atomic; // freestandingusing atomic_uint_fast16_t = atomic; // freestandingusing atomic_int_fast32_t = atomic; // freestandingusing atomic_uint_fast32_t = atomic; // freestandingusing atomic_int_fast64_t = atomic; // freestandingusing atomic_uint_fast64_t = atomic; // freestandingusing atomic_intptr_t = atomic; // freestandingusing atomic_uintptr_t = atomic; // freestandingusing atomic_size_t = atomic; // freestandingusing atomic_ptrdiff_t = atomic; // freestandingusing atomic_intmax_t = atomic; // freestandingusing atomic_uintmax_t = atomic; // 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}