Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/header/atomic"

From cppreference.com
< cpp‎ | header
m (link to zh)
(Header content update as per P0493R5.)
 
(15 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{cpp/header/title|atomic}}
+
{{cpp/header/title|atomic|notes={{mark c++11}}}}
 
{{cpp/header/navbar}}
 
{{cpp/header/navbar}}
This header is part of the [[cpp/atomic|atomic operations]] library.
+
This header is part of the [[cpp/thread|concurrency support]] library.
 
{{dsc begin}}
 
{{dsc begin}}
 
{{dsc h1|Classes}}
 
{{dsc h1|Classes}}
{{dsc inc | cpp/atomic/dsc atomic}}
+
{{dsc inc|cpp/atomic/dsc atomic}}
{{dsc inc | cpp/atomic/dsc atomic_flag}}
+
{{dsc inc|cpp/atomic/dsc atomic_ref}}
{{dsc inc | cpp/atomic/dsc memory_order}}
+
{{dsc inc|cpp/atomic/dsc atomic_flag}}
{{dsc h1|Typedefs}}
+
{{dsc inc|cpp/atomic/dsc memory_order}}
{{dsc | {{c|std::atomic_bool}} | {{c|std::atomic<bool>}} }}
+
{{dsc inc|cpp/atomic/atomic/dsc atomic integral types}}
{{dsc | {{c|std::atomic_char}} | {{c|std::atomic<char>}} }}
+
{{dsc inc|cpp/atomic/atomic/dsc atomic lock free aliases}}
{{dsc | {{c|std::atomic_schar}} | {{c|std::atomic<signed char>}} }}
+
{{dsc | {{c|std::atomic_uchar}} | {{c|std::atomic<unsigned char>}} }}
+
{{dsc | {{c|std::atomic_short}} | {{c|std::atomic<short>}} }}
+
{{dsc | {{c|std::atomic_ushort}} | {{c|std::atomic<unsigned short>}} }}
+
{{dsc | {{c|std::atomic_int}} | {{c|std::atomic<int>}} }}
+
{{dsc | {{c|std::atomic_uint}} | {{c|std::atomic<unsigned int>}} }}
+
{{dsc | {{c|std::atomic_long}} | {{c|std::atomic<long>}} }}
+
{{dsc | {{c|std::atomic_ulong}} | {{c|std::atomic<unsigned long>}} }}
+
{{dsc | {{c|std::atomic_llong}} | {{c|std::atomic<long long>}} }}
+
{{dsc | {{c|std::atomic_ullong}} | {{c|std::atomic<unsigned long long>}} }}
+
{{dsc | {{c|std::atomic_char16_t}} | {{c|std::atomic<char16_t>}} }}
+
{{dsc | {{c|std::atomic_char32_t}} | {{c|std::atomic<char32_t>}} }}
+
{{dsc | {{c|std::atomic_wchar_t}} | {{c|std::atomic<wchar_t>}} }}
+
{{dsc | {{c|std::atomic_int_least8_t}} | {{c|std::atomic<int_least8_t>}} }}
+
{{dsc | {{c|std::atomic_uint_least8_t}} | {{c|std::atomic<uint_least8_t>}} }}
+
{{dsc | {{c|std::atomic_int_least16_t}} | {{c|std::atomic<int_least16_t>}} }}
+
{{dsc | {{c|std::atomic_uint_least16_t}} | {{c|std::atomic<uint_least16_t>}} }}
+
{{dsc | {{c|std::atomic_int_least32_t}} | {{c|std::atomic<int_least32_t>}} }}
+
{{dsc | {{c|std::atomic_uint_least32_t}} | {{c|std::atomic<uint_least32_t>}} }}
+
{{dsc | {{c|std::atomic_int_least64_t}} | {{c|std::atomic<int_least64_t>}} }}
+
{{dsc | {{c|std::atomic_uint_least64_t}} | {{c|std::atomic<uint_least64_t>}} }}
+
{{dsc | {{c|std::atomic_int_fast8_t}} | {{c|std::atomic<int_fast8_t>}} }}
+
{{dsc | {{c|std::atomic_uint_fast8_t}} | {{c|std::atomic<uint_fast8_t>}} }}
+
{{dsc | {{c|std::atomic_int_fast16_t}} | {{c|std::atomic<int_fast16_t>}} }}
+
{{dsc | {{c|std::atomic_uint_fast16_t}} | {{c|std::atomic<uint_fast16_t>}} }}
+
{{dsc | {{c|std::atomic_int_fast32_t}} | {{c|std::atomic<int_fast32_t>}} }}
+
{{dsc | {{c|std::atomic_uint_fast32_t}} | {{c|std::atomic<uint_fast32_t>}} }}
+
{{dsc | {{c|std::atomic_int_fast64_t}} | {{c|std::atomic<int_fast64_t>}} }}
+
{{dsc | {{c|std::atomic_uint_fast64_t}} | {{c|std::atomic<uint_fast64_t>}} }}
+
{{dsc | {{c|std::atomic_intptr_t}} | {{c|std::atomic<intptr_t>}} }}
+
{{dsc | {{c|std::atomic_uintptr_t}} | {{c|std::atomic<uintptr_t>}} }}
+
{{dsc | {{c|std::atomic_size_t}} | {{c|std::atomic<size_t>}} }}
+
{{dsc | {{c|std::atomic_ptrdiff_t}} | {{c|std::atomic<ptrdiff_t>}} }}
+
{{dsc | {{c|std::atomic_intmax_t}} | {{c|std::atomic<intmax_t>}} }}
+
{{dsc | {{c|std::atomic_uintmax_t}} | {{c|std::atomic<uintmax_t>}} }}
+
 
{{dsc h1|Functions}}
 
{{dsc h1|Functions}}
{{dsc inc | cpp/atomic/dsc atomic_is_lock_free}}
+
{{dsc inc|cpp/atomic/dsc atomic_is_lock_free}}
{{dsc inc | cpp/atomic/dsc atomic_store}}
+
{{dsc inc|cpp/atomic/dsc atomic_store}}
{{dsc inc | cpp/atomic/dsc atomic_load}}
+
{{dsc inc|cpp/atomic/dsc atomic_load}}
{{dsc inc | cpp/atomic/dsc atomic_exchange}}
+
{{dsc inc|cpp/atomic/dsc atomic_exchange}}
{{dsc inc | cpp/atomic/dsc atomic_compare_exchange}}
+
{{dsc inc|cpp/atomic/dsc atomic_compare_exchange}}
{{dsc inc | cpp/atomic/dsc atomic_fetch_add}}
+
{{dsc inc|cpp/atomic/dsc atomic_fetch_add}}
{{dsc inc | cpp/atomic/dsc atomic_fetch_sub}}
+
{{dsc inc|cpp/atomic/dsc atomic_fetch_sub}}
{{dsc inc | cpp/atomic/dsc atomic_fetch_and}}
+
{{dsc inc|cpp/atomic/dsc atomic_fetch_and}}
{{dsc inc | cpp/atomic/dsc atomic_fetch_or}}
+
{{dsc inc|cpp/atomic/dsc atomic_fetch_or}}
{{dsc inc | cpp/atomic/dsc atomic_fetch_xor}}
+
{{dsc inc|cpp/atomic/dsc atomic_fetch_xor}}
{{dsc inc | cpp/atomic/dsc atomic_flag_test_and_set}}
+
{{dsc inc|cpp/atomic/dsc atomic_fetch_max}}
{{dsc inc | cpp/atomic/dsc atomic_flag_clear}}
+
{{dsc inc|cpp/atomic/dsc atomic_fetch_min}}
{{dsc inc | cpp/atomic/dsc atomic_init}}
+
{{dsc inc|cpp/atomic/dsc atomic_wait}}
{{dsc inc | cpp/atomic/dsc kill_dependency}}
+
{{dsc inc|cpp/atomic/dsc atomic_notify_one}}
{{dsc inc | cpp/atomic/dsc atomic_thread_fence}}
+
{{dsc inc|cpp/atomic/dsc atomic_notify_all}}
{{dsc inc | cpp/atomic/dsc atomic_signal_fence}}
+
{{dsc inc|cpp/atomic/dsc atomic_flag_test}}
{{dsc h1|Preprocessor macros}}
+
{{dsc inc|cpp/atomic/dsc atomic_flag_test_and_set}}
{{dsc inc | cpp/atomic/dsc ATOMIC_VAR_INIT}}
+
{{dsc inc|cpp/atomic/dsc atomic_flag_clear}}
{{dsc inc | cpp/atomic/dsc ATOMIC_FLAG_INIT}}
+
{{dsc inc|cpp/atomic/dsc atomic_flag_wait}}
 +
{{dsc inc|cpp/atomic/dsc atomic_flag_notify_one}}
 +
{{dsc inc|cpp/atomic/dsc atomic_flag_notify_all}}
 +
{{dsc inc|cpp/atomic/dsc atomic_init}}
 +
{{dsc inc|cpp/atomic/dsc kill_dependency}}
 +
{{dsc inc|cpp/atomic/dsc atomic_thread_fence}}
 +
{{dsc inc|cpp/atomic/dsc atomic_signal_fence}}
 +
{{dsc h1|Macros}}
 +
{{dsc inc|cpp/atomic/dsc ATOMIC_VAR_INIT}}
 +
{{dsc inc|cpp/atomic/dsc ATOMIC_FLAG_INIT}}
 
{{dsc end}}
 
{{dsc end}}
  
 
===Synopsis===
 
===Synopsis===
 +
{{cpp/synopsis/atomic}}
  
{{source|1=
+
{{langlinks|de|es|ja|ru|zh}}
namespace std {
+
    typedef enum memory_order {
+
        memory_order_relaxed,
+
        memory_order_consume,
+
        memory_order_acquire,
+
        memory_order_release,
+
        memory_order_acq_rel,
+
        memory_order_seq_cst
+
    } memory_order;
+
 
+
    template <class T>
+
    T kill_dependency(T y) noexcept;
+
 
+
    // lock-free property
+
    #define ATOMIC_BOOL_LOCK_FREE /*unspecified*/
+
    #define ATOMIC_CHAR_LOCK_FREE /*unspecified*/
+
    #define ATOMIC_CHAR16_T_LOCK_FREE /*unspecified*/
+
    #define ATOMIC_CHAR32_T_LOCK_FREE /*unspecified*/
+
    #define ATOMIC_WCHAR_T_LOCK_FREE /*unspecified*/
+
    #define ATOMIC_SHORT_LOCK_FREE /*unspecified*/
+
    #define ATOMIC_INT_LOCK_FREE /*unspecified*/
+
    #define ATOMIC_LONG_LOCK_FREE /*unspecified*/
+
    #define ATOMIC_LLONG_LOCK_FREE /*unspecified*/
+
    #define ATOMIC_POINTER_LOCK_FREE /*unspecified*/
+
+
    // generic atomic type
+
    template<class T> struct atomic;
+
    // specialization for integral types
+
    template<> struct atomic</*integral*/>;
+
    // specialization for pointers
+
    template<class T> struct atomic<T*>;
+
 
+
    // named typedefs
+
    typedef atomic<bool> atomic_bool;
+
    typedef atomic<char> atomic_char;
+
    typedef atomic<signed char> atomic_schar;
+
    typedef atomic<unsigned char> atomic_uchar;
+
    typedef atomic<short> atomic_short;
+
    typedef atomic<unsigned short> atomic_ushort;
+
    typedef atomic<int> atomic_int;
+
    typedef atomic<unsigned int> atomic_uint;
+
    typedef atomic<long> atomic_long;
+
    typedef atomic<unsigned long> atomic_ulong;
+
    typedef atomic<long long> atomic_llong;
+
    typedef atomic<unsigned long long> atomic_ullong;
+
    typedef atomic<char16_t> atomic_char16_t;
+
    typedef atomic<char32_t> atomic_char32_t;
+
    typedef atomic<wchar_t> atomic_wchar_t;
+
    typedef atomic<int_least8_t> atomic_int_least8_t;
+
    typedef atomic<uint_least8_t> atomic_uint_least8_t;
+
    typedef atomic<int_least16_t> atomic_int_least16_t;
+
    typedef atomic<uint_least16_t> atomic_uint_least16_t;
+
    typedef atomic<int_least32_t> atomic_int_least32_t;
+
    typedef atomic<uint_least32_t> atomic_uint_least32_t;
+
    typedef atomic<int_least64_t> atomic_int_least64_t;
+
    typedef atomic<uint_least64_t> atomic_uint_least64_t;
+
    typedef atomic<int_fast8_t> atomic_int_fast8_t;
+
    typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
+
    typedef atomic<int_fast16_t> atomic_int_fast16_t;
+
    typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
+
    typedef atomic<int_fast32_t> atomic_int_fast32_t;
+
    typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
+
    typedef atomic<int_fast64_t> atomic_int_fast64_t;
+
    typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
+
    typedef atomic<intptr_t> atomic_intptr_t;
+
    typedef atomic<uintptr_t> atomic_uintptr_t;
+
    typedef atomic<size_t> atomic_size_t;
+
    typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
+
    typedef atomic<intmax_t> atomic_intmax_t;
+
    typedef atomic<uintmax_t> atomic_uintmax_t;
+
 
+
    // general operations on atomic types
+
    // /*atomic-type*/ is either atomic<T> or one of the typedefs
+
    // (if it's atomic<T>, then template<class T> is implied)
+
    bool atomic_is_lock_free(const volatile /*atomic-type*/ *) noexcept;
+
    bool atomic_is_lock_free(const /*atomic-type*/ *) noexcept;
+
    void atomic_init(volatile /*atomic-type*/ *, T) noexcept;
+
    void atomic_init(/*atomic-type*/ *, T) noexcept;
+
    void atomic_store(volatile /*atomic-type*/ *, T) noexcept;
+
    void atomic_store(/*atomic-type*/ *, T) noexcept;
+
    void atomic_store_explicit(volatile /*atomic-type*/ *, T, memory_order) noexcept;
+
    void atomic_store_explicit(/*atomic-type*/ *, T, memory_order) noexcept;
+
    T atomic_load(const volatile /*atomic-type*/ *) noexcept;
+
    T atomic_load(const /*atomic-type*/ *) noexcept;
+
    T atomic_load_explicit(const volatile /*atomic-type*/ *, memory_order) noexcept;
+
    T atomic_load_explicit(const /*atomic-type*/ *, memory_order) noexcept;
+
    T atomic_exchange(volatile /*atomic-type*/ *, T) noexcept;
+
    T atomic_exchange(/*atomic-type*/ *, T) noexcept;
+
    T atomic_exchange_explicit(volatile /*atomic-type*/ *, T, memory_order) noexcept;
+
    T atomic_exchange_explicit(/*atomic-type*/ *, T, memory_order) noexcept;
+
    bool atomic_compare_exchange_weak(volatile /*atomic-type*/ *, T*, T) noexcept;
+
    bool atomic_compare_exchange_weak(/*atomic-type*/ *, T*, T) noexcept;
+
    bool atomic_compare_exchange_strong(volatile /*atomic-type*/ *, T*, T) noexcept;
+
    bool atomic_compare_exchange_strong(/*atomic-type*/ *, T*, T) noexcept;
+
    bool atomic_compare_exchange_weak_explicit(volatile /*atomic-type*/ *, T*, T,
+
                                              memory_order, memory_order) noexcept;
+
    bool atomic_compare_exchange_weak_explicit(/*atomic-type*/ *, T*, T.
+
                                              memory_order, memory_order) noexcept;
+
    bool atomic_compare_exchange_strong_explicit(volatile /*atomic-type*/ *, T*, T,
+
                                                memory_order, memory_order) noexcept;
+
    bool atomic_compare_exchange_strong_explicit(/*atomic-type*/ *, T*, T,
+
                                                memory_order, memory_order) noexcept;
+
 
+
    // templated operations on atomic types (declared, but not defined)
+
    template <class T>
+
    T atomic_fetch_add(volatile atomic<T>*, T) noexcept;
+
    template <class T>
+
    T atomic_fetch_add(atomic<T>*, T) noexcept;
+
    template <class T>
+
    T atomic_fetch_add_explicit(volatile atomic<T>*, T, memory_order) noexcept;
+
    template <class T>
+
    T atomic_fetch_add_explicit(atomic<T>*, T, memory_order) noexcept;
+
    template <class T>
+
    T atomic_fetch_sub(volatile atomic<T>*, T) noexcept;
+
    template <class T>
+
    T atomic_fetch_sub(atomic<T>*, T) noexcept;
+
    template <class T>
+
    T atomic_fetch_sub_explicit(volatile atomic<T>*, T, memory_order) noexcept;
+
    template <class T>
+
    T atomic_fetch_sub_explicit(atomic<T>*, T, memory_order) noexcept;
+
    template <class T>
+
    T atomic_fetch_and(volatile atomic<T>*, T) noexcept;
+
    template <class T>
+
    T atomic_fetch_and(atomic<T>*, T) noexcept;
+
    template <class T>
+
    T atomic_fetch_and_explicit(volatile atomic<T>*, T, memory_order) noexcept;
+
    template <class T>
+
    T atomic_fetch_and_explicit(atomic<T>*, T, memory_order) noexcept;
+
    template <class T>
+
    T atomic_fetch_or(volatile atomic<T>*, T) noexcept;
+
    template <class T>
+
    T atomic_fetch_or(atomic<T>*, T) noexcept;
+
    template <class T>
+
    T atomic_fetch_or_explicit(volatile atomic<T>*, T, memory_order) noexcept;
+
    template <class T>
+
    T atomic_fetch_or_explicit(atomic<T>*, T, memory_order) noexcept;
+
    template <class T>
+
    T atomic_fetch_xor(volatile atomic<T>*, T) noexcept;
+
    template <class T>
+
    T atomic_fetch_xor(atomic<T>*, T) noexcept;
+
    template <class T>
+
    T atomic_fetch_xor_explicit(volatile atomic<T>*, T, memory_order) noexcept;
+
    template <class T>
+
    T atomic_fetch_xor_explicit(atomic<T>*, T, memory_order) noexcept;
+
 
+
    // arithmetic operations on atomic types
+
    // /*atomic-integral*/ is either atomic<T> or one of the typedefs
+
    // (if it's atomic<T>, then template<> is implied)
+
    /*integral*/ atomic_fetch_add(volatile /*atomic-integral*/ *,
+
                                  /*integral*/ ) noexcept;
+
    /*integral*/ atomic_fetch_add(/*atomic-integral*/ *,
+
                                  /*integral*/ ) noexcept;
+
    /*integral*/ atomic_fetch_add_explicit(volatile /*atomic-integral*/ *,
+
                                          /*integral*/,
+
                                            memory_order) noexcept;
+
    /*integral*/ atomic_fetch_add_explicit(/*atomic-integral*/ *,
+
                                          /*integral*/,
+
                                          memory_order) noexcept;
+
    /*integral*/ atomic_fetch_sub(volatile /*atomic-integral*/ *,
+
                                  /*integral*/ ) noexcept;
+
    /*integral*/ atomic_fetch_sub(/*atomic-integral*/ *,
+
                                  /*integral*/ ) noexcept;
+
    /*integral*/ atomic_fetch_sub_explicit(volatile /*atomic-integral*/ *,
+
                                          /*integral*/ ,
+
                                          memory_order) noexcept;
+
    /*integral*/ atomic_fetch_sub_explicit(/*atomic-integral*/ *,
+
                                          /*integral*/ ,
+
                                          memory_order) noexcept;
+
    /*integral*/ atomic_fetch_and(volatile /*atomic-integral*/ *,
+
                                  /*integral*/ ) noexcept;
+
    /*integral*/ atomic_fetch_and(/*atomic-integral*/ *,
+
                                  /*integral*/ ) noexcept;
+
    /*integral*/ atomic_fetch_and_explicit(volatile /*atomic-integral*/ *,
+
                                          /*integral*/ ,
+
                                          memory_order) noexcept;
+
    /*integral*/ atomic_fetch_and_explicit(/*atomic-integral*/ *,
+
                                          /*integral*/ ,
+
                                          memory_order) noexcept;
+
    /*integral*/ atomic_fetch_or(volatile /*atomic-integral*/ *,
+
                                /*integral*/ ) noexcept;
+
    /*integral*/ atomic_fetch_or(/*atomic-integral*/ *,
+
                                /*integral*/ ) noexcept;
+
    /*integral*/ atomic_fetch_or_explicit(volatile /*atomic-integral*/ *,
+
                                          /*integral*/ ,
+
                                          memory_order) noexcept;
+
    /*integral*/ atomic_fetch_or_explicit(/*atomic-integral*/ *,
+
                                          /*integral*/ ,
+
                                          memory_order) noexcept;
+
    /*integral*/ atomic_fetch_xor(volatile /*atomic-integral*/ *,
+
                                  /*integral*/ ) noexcept;
+
    /*integral*/ atomic_fetch_xor(/*atomic-integral*/ *,
+
                                  /*integral*/ ) noexcept;
+
    /*integral*/ atomic_fetch_xor_explicit(volatile /*atomic-integral*/ *,
+
                                          /*integral*/ , memory_order) noexcept;
+
    /*integral*/ atomic_fetch_xor_explicit(/*atomic-integral*/ *,
+
                                          /*integral*/ ,
+
                                          memory_order) noexcept;
+
 
+
    // partial specializations for pointers
+
    template <class T>
+
    T* atomic_fetch_add(volatile atomic<T*>*, ptrdiff_t) noexcept;
+
    template <class T>
+
    T* atomic_fetch_add(atomic<T*>*, ptrdiff_t) noexcept;
+
    template <class T>
+
    T* atomic_fetch_add_explicit(volatile atomic<T*>*,
+
                                ptrdiff_t, memory_order) noexcept;
+
    template <class T>
+
    T* atomic_fetch_add_explicit(atomic<T*>*, ptrdiff_t, memory_order) noexcept;
+
    template <class T>
+
    T* atomic_fetch_sub(volatile atomic<T*>*, ptrdiff_t) noexcept;
+
    template <class T>
+
    T* atomic_fetch_sub(atomic<T*>*, ptrdiff_t) noexcept;
+
    template <class T>
+
    T* atomic_fetch_sub_explicit(volatile atomic<T*>*,
+
                                ptrdiff_t, memory_order) noexcept;
+
    template <class T>
+
    T* atomic_fetch_sub_explicit(atomic<T*>*, ptrdiff_t, memory_order) noexcept;
+
 
+
    // initialization
+
    #define ATOMIC_VAR_INIT(value) /*see description*/
+
 
+
    // flag type and operations
+
    struct atomic_flag;
+
 
+
    bool atomic_flag_test_and_set(volatile atomic_flag*) noexcept;
+
    bool atomic_flag_test_and_set(atomic_flag*) noexcept;
+
    bool atomic_flag_test_and_set_explicit(volatile atomic_flag*,
+
                                          memory_order) noexcept;
+
    bool atomic_flag_test_and_set_explicit(atomic_flag*, memory_order) noexcept;
+
    void atomic_flag_clear(volatile atomic_flag*) noexcept;
+
    void atomic_flag_clear(atomic_flag*) noexcept;
+
    void atomic_flag_clear_explicit(volatile atomic_flag*, memory_order) noexcept;
+
    void atomic_flag_clear_explicit(atomic_flag*, memory_order) noexcept;
+
 
+
    #define ATOMIC_FLAG_INIT /*see description*/
+
 
+
    // fences
+
    extern "C" void atomic_thread_fence(memory_order) noexcept;
+
    extern "C" void atomic_signal_fence(memory_order) noexcept;
+
}}
+
 
+
====Class {{lc|std::atomic}}====
+
{{source|1=
+
template <class T> struct atomic {
+
    bool is_lock_free() const volatile noexcept;
+
    bool is_lock_free() const noexcept;
+
    void store(T, memory_order = memory_order_seq_cst) volatile noexcept;
+
    void store(T, memory_order = memory_order_seq_cst) noexcept;
+
    T load(memory_order = memory_order_seq_cst) const volatile noexcept;
+
    T load(memory_order = memory_order_seq_cst) const noexcept;
+
    operator T() const volatile noexcept;
+
    operator T() const noexcept;
+
    T exchange(T, memory_order = memory_order_seq_cst) volatile noexcept;
+
    T exchange(T, memory_order = memory_order_seq_cst) noexcept;
+
    bool compare_exchange_weak(T&, T,
+
                              memory_order, memory_order) volatile noexcept;
+
    bool compare_exchange_weak(T&, T,
+
                              memory_order, memory_order) noexcept;
+
    bool compare_exchange_strong(T&, T,
+
                                memory_order, memory_order) volatile noexcept;
+
    bool compare_exchange_strong(T&, T,
+
                                memory_order, memory_order) noexcept;
+
    bool compare_exchange_weak(T&, T,
+
                              memory_order = memory_order_seq_cst) volatile noexcept;
+
    bool compare_exchange_weak(T&, T,
+
                              memory_order = memory_order_seq_cst) noexcept;
+
    bool compare_exchange_strong(T&, T,
+
                                memory_order = memory_order_seq_cst) volatile noexcept;
+
    bool compare_exchange_strong(T&, T,
+
                                memory_order = memory_order_seq_cst) noexcept;
+
 
+
    atomic() noexcept = default;
+
    constexpr atomic(T) noexcept;
+
    atomic(const atomic&) = delete;
+
    atomic& operator=(const atomic&) = delete;
+
    atomic& operator=(const atomic&) volatile = delete;
+
    T operator=(T) volatile noexcept;
+
    T operator=(T) noexcept;
+
};
+
}}
+
 
+
====Specialization of {{lc|std::atomic}} for integral types====
+
{{source|1=
+
template<> struct atomic</*integral*/> {
+
    bool is_lock_free() const volatile noexcept;
+
    bool is_lock_free() const noexcept;
+
    void store(/*integral*/,
+
              memory_order = memory_order_seq_cst) volatile noexcept;
+
    void store(/*integral*/,
+
              memory_order = memory_order_seq_cst) noexcept;
+
    /*integral*/ load(memory_order = memory_order_seq_cst) const volatile noexcept;
+
    /*integral*/ load(memory_order = memory_order_seq_cst) const noexcept;
+
    operator /*integral*/() const volatile noexcept;
+
    operator /*integral*/() const noexcept;
+
    /*integral*/ exchange(/*integral*/,
+
                          memory_order = memory_order_seq_cst) volatile noexcept;
+
    /*integral*/ exchange(/*integral*/,
+
                          memory_order = memory_order_seq_cst) noexcept;
+
    bool compare_exchange_weak(/*integral*/&, /*integral*/,
+
                              memory_order, memory_order) volatile noexcept;
+
    bool compare_exchange_weak(/*integral*/&, /*integral*/,
+
                              memory_order, memory_order) noexcept;
+
    bool compare_exchange_strong(/*integral*/&, /*integral*/,
+
                                memory_order, memory_order) volatile noexcept;
+
    bool compare_exchange_strong(/*integral*/&, /*integral*/,
+
                                memory_order, memory_order) noexcept;
+
    bool compare_exchange_weak(/*integral*/&, /*integral*/,
+
                              memory_order = memory_order_seq_cst) volatile noexcept;
+
    bool compare_exchange_weak(/*integral*/&, /*integral*/,
+
                              memory_order = memory_order_seq_cst) noexcept;
+
    bool compare_exchange_strong(/*integral*/&, /*integral*/,
+
                                memory_order = memory_order_seq_cst) volatile noexcept;
+
    bool compare_exchange_strong(/*integral*/&, /*integral*/,
+
                                memory_order = memory_order_seq_cst) noexcept;
+
    /*integral*/ fetch_add(/*integral*/,
+
                          memory_order = memory_order_seq_cst) volatile noexcept;
+
    /*integral*/ fetch_add(/*integral*/,
+
                          memory_order = memory_order_seq_cst) noexcept;
+
    /*integral*/ fetch_sub(/*integral*/,
+
                          memory_order = memory_order_seq_cst) volatile noexcept;
+
    /*integral*/ fetch_sub(/*integral*/,
+
                          memory_order = memory_order_seq_cst) noexcept;
+
    /*integral*/ fetch_and(/*integral*/,
+
                          memory_order = memory_order_seq_cst) volatile noexcept;
+
    /*integral*/ fetch_and(/*integral*/,
+
                          memory_order = memory_order_seq_cst) noexcept;
+
    /*integral*/ fetch_or(/*integral*/,
+
                          memory_order = memory_order_seq_cst) volatile noexcept;
+
    /*integral*/ fetch_or(/*integral*/,
+
                          memory_order = memory_order_seq_cst) noexcept;
+
    /*integral*/ fetch_xor(/*integral*/,
+
                          memory_order = memory_order_seq_cst) volatile noexcept;
+
    /*integral*/ fetch_xor(/*integral*/,
+
                          memory_order = memory_order_seq_cst) noexcept;
+
 
+
    atomic() noexcept = default;
+
    constexpr atomic(/*integral*/) noexcept;
+
    atomic(const atomic&) = delete;
+
    atomic& operator=(const atomic&) = delete;
+
    atomic& operator=(const atomic&) volatile = delete;
+
    /*integral*/ operator=(/*integral*/) volatile noexcept;
+
    /*integral*/ operator=(/*integral*/) noexcept;
+
    /*integral*/ operator++(int) volatile noexcept;
+
    /*integral*/ operator++(int) noexcept;
+
    /*integral*/ operator--(int) volatile noexcept;
+
    /*integral*/ operator--(int) noexcept;
+
    /*integral*/ operator++() volatile noexcept;
+
    /*integral*/ operator++() noexcept;
+
    /*integral*/ operator--() volatile noexcept;
+
    /*integral*/ operator--() noexcept;
+
    /*integral*/ operator+=(/*integral*/) volatile noexcept;
+
    /*integral*/ operator+=(/*integral*/) noexcept;
+
    /*integral*/ operator-=(/*integral*/) volatile noexcept;
+
    /*integral*/ operator-=(/*integral*/) noexcept;
+
    /*integral*/ operator&=(/*integral*/) volatile noexcept;
+
    /*integral*/ operator&=(/*integral*/) noexcept;
+
    /*integral*/ operator{{!}}=(/*integral*/) volatile noexcept;
+
    /*integral*/ operator{{!}}=(/*integral*/) noexcept;
+
    /*integral*/ operator^=(/*integral*/) volatile noexcept;
+
    /*integral*/ operator^=(/*integral*/) noexcept;
+
};
+
}}
+
 
+
====Specialization of {{lc|std::atomic}} for pointer types====
+
{{source|1=
+
template <class T> struct atomic<T*> {
+
    bool is_lock_free() const volatile noexcept;
+
    bool is_lock_free() const noexcept;
+
    void store(T*, memory_order = memory_order_seq_cst) volatile noexcept;
+
    void store(T*, memory_order = memory_order_seq_cst) noexcept;
+
    T* load(memory_order = memory_order_seq_cst) const volatile noexcept;
+
    T* load(memory_order = memory_order_seq_cst) const noexcept;
+
    operator T*() const volatile noexcept;
+
    operator T*() const noexcept;
+
    T* exchange(T*, memory_order = memory_order_seq_cst) volatile noexcept;
+
    T* exchange(T*, memory_order = memory_order_seq_cst) noexcept;
+
    bool compare_exchange_weak(T*&, T*, memory_order, memory_order) volatile noexcept;
+
    bool compare_exchange_weak(T*&, T*, memory_order, memory_order) noexcept;
+
    bool compare_exchange_strong(T*&, T*, memory_order, memory_order) volatile noexcept;
+
    bool compare_exchange_strong(T*&, T*, memory_order, memory_order) noexcept;
+
    bool compare_exchange_weak(T*&, T*,
+
                              memory_order = memory_order_seq_cst) volatile noexcept;
+
    bool compare_exchange_weak(T*&, T*,
+
                              memory_order = memory_order_seq_cst) noexcept;
+
    bool compare_exchange_strong(T*&, T*,
+
                                memory_order = memory_order_seq_cst) volatile noexcept;
+
    bool compare_exchange_strong(T*&, T*,
+
                                memory_order = memory_order_seq_cst) noexcept;
+
    T* fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst) volatile noexcept;
+
    T* fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst) noexcept;
+
    T* fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst) volatile noexcept;
+
    T* fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst) noexcept;
+
 
+
    atomic() noexcept = default;
+
    constexpr atomic(T*) noexcept;
+
    atomic(const atomic&) = delete;
+
    atomic& operator=(const atomic&) = delete;
+
    atomic& operator=(const atomic&) volatile = delete;
+
    T* operator=(T*) volatile noexcept;
+
    T* operator=(T*) noexcept;
+
    T* operator++(int) volatile noexcept;
+
    T* operator++(int) noexcept;
+
    T* operator--(int) volatile noexcept;
+
    T* operator--(int) noexcept;
+
    T* operator++() volatile noexcept;
+
    T* operator++() noexcept;
+
    T* operator--() volatile noexcept;
+
    T* operator--() noexcept;
+
    T* operator+=(ptrdiff_t) volatile noexcept;
+
    T* operator+=(ptrdiff_t) noexcept;
+
    T* operator-=(ptrdiff_t) volatile noexcept;
+
    T* operator-=(ptrdiff_t) noexcept;
+
};
+
}}
+
 
+
====Class {{lc|std::atomic_flag}}====
+
{{source|1=
+
typedef struct atomic_flag {
+
    bool test_and_set(memory_order = memory_order_seq_cst) volatile noexcept;
+
    bool test_and_set(memory_order = memory_order_seq_cst) noexcept;
+
    void clear(memory_order = memory_order_seq_cst) volatile noexcept;
+
    void clear(memory_order = memory_order_seq_cst) noexcept;
+
    atomic_flag() noexcept = default;
+
    atomic_flag(const atomic_flag&) = delete;
+
    atomic_flag& operator=(const atomic_flag&) = delete;
+
    atomic_flag& operator=(const atomic_flag&) volatile = delete;
+
} atomic_flag;
+
}}
+
 
+
{{langlinks|zh}}
+

Latest revision as of 19:19, 5 May 2024

 
 
Standard library headers
 

This header is part of the concurrency support library.

Contents

Classes

(C++11)
atomic class template and specializations for bool, integral, floating-point,(since C++20) and pointer types
(class template) [edit]
provides atomic operations on non-atomic objects
(class template) [edit]
the lock-free boolean atomic type
(class) [edit]
defines memory ordering constraints for the given atomic operation
(enum) [edit]
std::atomic<bool>
(typedef) [edit]
std::atomic<char>
(typedef) [edit]
std::atomic<signed char>
(typedef) [edit]
std::atomic<unsigned char>
(typedef) [edit]
std::atomic<short>
(typedef) [edit]
std::atomic<unsigned short>
(typedef) [edit]
std::atomic<int>
(typedef) [edit]
std::atomic<unsigned int>
(typedef) [edit]
std::atomic<long>
(typedef) [edit]
std::atomic<unsigned long>
(typedef) [edit]
std::atomic<long long>
(typedef) [edit]
std::atomic<unsigned long long>
(typedef) [edit]
std::atomic<char8_t>
(typedef) [edit]
std::atomic<char16_t>
(typedef) [edit]
std::atomic<char32_t>
(typedef) [edit]
std::atomic<wchar_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::int8_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::uint8_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::int16_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::uint16_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::int32_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::uint32_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::int64_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::uint64_t>
(typedef) [edit]
std::atomic<std::int_least8_t>
(typedef) [edit]
std::atomic<std::uint_least8_t>
(typedef) [edit]
std::atomic<std::int_least16_t>
(typedef) [edit]
std::atomic<std::uint_least16_t>
(typedef) [edit]
std::atomic<std::int_least32_t>
(typedef) [edit]
std::atomic<std::uint_least32_t>
(typedef) [edit]
std::atomic<std::int_least64_t>
(typedef) [edit]
std::atomic<std::uint_least64_t>
(typedef) [edit]
std::atomic<std::int_fast8_t>
(typedef) [edit]
std::atomic<std::uint_fast8_t>
(typedef) [edit]
std::atomic<std::int_fast16_t>
(typedef) [edit]
std::atomic<std::uint_fast16_t>
(typedef) [edit]
std::atomic<std::int_fast32_t>
(typedef) [edit]
std::atomic<std::uint_fast32_t>
(typedef) [edit]
std::atomic<std::int_fast64_t>
(typedef) [edit]
std::atomic<std::uint_fast64_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::intptr_t>
(typedef) [edit]
(C++11)(optional)
std::atomic<std::uintptr_t>
(typedef) [edit]
std::atomic<std::size_t>
(typedef) [edit]
std::atomic<std::ptrdiff_t>
(typedef) [edit]
std::atomic<std::intmax_t>
(typedef) [edit]
std::atomic<std::uintmax_t>
(typedef) [edit]
a signed integral atomic type that is lock-free and for which waiting/notifying is most efficient
(typedef) [edit]
an unsigned integral atomic type that is lock-free and for which waiting/notifying is most efficient
(typedef) [edit]

Functions

checks if the atomic type's operations are lock-free
(function template) [edit]
atomically replaces the value of the atomic object with a non-atomic argument
(function template) [edit]
atomically obtains the value stored in an atomic object
(function template) [edit]
atomically replaces the value of the atomic object with non-atomic argument and returns the old value of the atomic
(function template) [edit]
atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not
(function template) [edit]
adds a non-atomic value to an atomic object and obtains the previous value of the atomic
(function template) [edit]
subtracts a non-atomic value from an atomic object and obtains the previous value of the atomic
(function template) [edit]
replaces the atomic object with the result of bitwise AND with a non-atomic argument and obtains the previous value of the atomic
(function template) [edit]
replaces the atomic object with the result of bitwise 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 bitwise XOR with a non-atomic argument and obtains the previous value of the atomic
(function template) [edit]
replaces the atomic object with the result of std::max with a non-atomic argument and obtains the previous value of the atomic
(function template) [edit]
replaces the atomic object with the result of std::min with a non-atomic argument and obtains the previous value of the atomic
(function template) [edit]
blocks the thread until notified and the atomic value changes
(function template) [edit]
notifies a thread blocked in atomic_wait
(function template) [edit]
notifies all threads blocked in atomic_wait
(function template) [edit]
atomically returns the value of the flag
(function) [edit]
atomically sets the flag to true and returns its previous value
(function) [edit]
atomically sets the value of the flag to false
(function) [edit]
blocks the thread until notified and the flag changes
(function) [edit]
notifies a thread blocked in atomic_flag_wait
(function) [edit]
notifies all threads blocked in atomic_flag_wait
(function) [edit]
(C++11)(deprecated in C++20)
non-atomic initialization of a default-constructed atomic object
(function template) [edit]
removes the specified object from the std::memory_order_consume dependency tree
(function template) [edit]
generic memory order-dependent fence synchronization primitive
(function) [edit]
fence between a thread and a signal handler executed in the same thread
(function) [edit]

Macros

(C++11)(deprecated in C++20)
constant initialization of an atomic variable of static storage duration
(function macro) [edit]
initializes an std::atomic_flag to false
(macro constant) [edit]

[edit] Synopsis

namespace std {
  /* until C++20:
  enum memory_order {
    memory_order_relaxed,
    memory_order_consume,
    memory_order_acquire,
    memory_order_release,
    memory_order_acq_rel,
    memory_order_seq_cst
  };
  */
 
  enum class memory_order : /* unspecified */;
  inline constexpr memory_order memory_order_relaxed = memory_order::relaxed;
  inline constexpr memory_order memory_order_consume = memory_order::consume;
  inline constexpr memory_order memory_order_acquire = memory_order::acquire;
  inline constexpr memory_order memory_order_release = memory_order::release;
  inline constexpr memory_order memory_order_acq_rel = memory_order::acq_rel;
  inline constexpr memory_order memory_order_seq_cst = memory_order::seq_cst;
 
  template<class T>
    T kill_dependency(T y) noexcept;
 
  // lock-free property
  #define ATOMIC_BOOL_LOCK_FREE /* unspecified */
  #define ATOMIC_CHAR_LOCK_FREE /* unspecified */
  #define ATOMIC_CHAR8_T_LOCK_FREE /* unspecified */
  #define ATOMIC_CHAR16_T_LOCK_FREE /* unspecified */
  #define ATOMIC_CHAR32_T_LOCK_FREE /* unspecified */
  #define ATOMIC_WCHAR_T_LOCK_FREE /* unspecified */
  #define ATOMIC_SHORT_LOCK_FREE /* unspecified */
  #define ATOMIC_INT_LOCK_FREE /* unspecified */
  #define ATOMIC_LONG_LOCK_FREE /* unspecified */
  #define ATOMIC_LLONG_LOCK_FREE /* unspecified */
  #define ATOMIC_POINTER_LOCK_FREE /* unspecified */
 
  // class template atomic_ref
  template<class T> struct atomic_ref;
  // partial specialization for pointers
  template<class T> struct atomic_ref<T*>;
 
  // class template atomic
  template<class T> struct atomic;
  // partial specialization for pointers
  template<class T> struct atomic<T*>;
 
  // non-member functions
  template<class T>
    bool atomic_is_lock_free(const volatile atomic<T>*) noexcept;
  template<class T>
    bool atomic_is_lock_free(const atomic<T>*) noexcept;
  template<class T>
    void atomic_store(volatile atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    void atomic_store(atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    void atomic_store_explicit(volatile atomic<T>*, typename atomic<T>::value_type,
                               memory_order) noexcept;
  template<class T>
    void atomic_store_explicit(atomic<T>*, typename atomic<T>::value_type,
                               memory_order) noexcept;
  template<class T>
    T atomic_load(const volatile atomic<T>*) noexcept;
  template<class T>
    T atomic_load(const atomic<T>*) noexcept;
  template<class T>
    T atomic_load_explicit(const volatile atomic<T>*, memory_order) noexcept;
  template<class T>
    T atomic_load_explicit(const atomic<T>*, memory_order) noexcept;
  template<class T>
    T atomic_exchange(volatile atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    T atomic_exchange(atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    T atomic_exchange_explicit(volatile atomic<T>*, typename atomic<T>::value_type,
                               memory_order) noexcept;
  template<class T>
    T atomic_exchange_explicit(atomic<T>*, typename atomic<T>::value_type,
                               memory_order) noexcept;
  template<class T>
    bool atomic_compare_exchange_weak(volatile atomic<T>*,
                                      typename atomic<T>::value_type*,
                                      typename atomic<T>::value_type) noexcept;
  template<class T>
    bool atomic_compare_exchange_weak(atomic<T>*,
                                      typename atomic<T>::value_type*,
                                      typename atomic<T>::value_type) noexcept;
  template<class T>
    bool atomic_compare_exchange_strong(volatile atomic<T>*,
                                        typename atomic<T>::value_type*,
                                        typename atomic<T>::value_type) noexcept;
  template<class T>
    bool atomic_compare_exchange_strong(atomic<T>*,
                                        typename atomic<T>::value_type*,
                                        typename atomic<T>::value_type) noexcept;
  template<class T>
    bool atomic_compare_exchange_weak_explicit(volatile atomic<T>*,
                                               typename atomic<T>::value_type*,
                                               typename atomic<T>::value_type,
                                               memory_order, memory_order) noexcept;
  template<class T>
    bool atomic_compare_exchange_weak_explicit(atomic<T>*,
                                               typename 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>*,
                                                 typename atomic<T>::value_type*,
                                                 typename atomic<T>::value_type,
                                                 memory_order, memory_order) noexcept;
  template<class T>
    bool atomic_compare_exchange_strong_explicit(atomic<T>*,
                                                 typename atomic<T>::value_type*,
                                                 typename atomic<T>::value_type,
                                                 memory_order, memory_order) noexcept;
 
  template<class T>
    T atomic_fetch_add(volatile atomic<T>*, typename atomic<T>::difference_type) noexcept;
  template<class T>
    T atomic_fetch_add(atomic<T>*, typename atomic<T>::difference_type) noexcept;
  template<class T>
    T atomic_fetch_add_explicit(volatile atomic<T>*, typename atomic<T>::difference_type,
                                memory_order) noexcept;
  template<class T>
    T atomic_fetch_add_explicit(atomic<T>*, typename atomic<T>::difference_type,
                                memory_order) noexcept;
  template<class T>
    T atomic_fetch_sub(volatile atomic<T>*, typename atomic<T>::difference_type) noexcept;
  template<class T>
    T atomic_fetch_sub(atomic<T>*, typename atomic<T>::difference_type) noexcept;
  template<class T>
    T atomic_fetch_sub_explicit(volatile atomic<T>*, typename atomic<T>::difference_type,
                                memory_order) noexcept;
  template<class T>
    T atomic_fetch_sub_explicit(atomic<T>*, typename atomic<T>::difference_type,
                                memory_order) noexcept;
  template<class T>
    T atomic_fetch_and(volatile atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    T atomic_fetch_and(atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    T atomic_fetch_and_explicit(volatile atomic<T>*, typename atomic<T>::value_type,
                                memory_order) noexcept;
  template<class T>
    T atomic_fetch_and_explicit(atomic<T>*, typename atomic<T>::value_type,
                                memory_order) noexcept;
  template<class T>
    T atomic_fetch_or(volatile atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    T atomic_fetch_or(atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    T atomic_fetch_or_explicit(volatile atomic<T>*, typename atomic<T>::value_type,
                               memory_order) noexcept;
  template<class T>
    T atomic_fetch_or_explicit(atomic<T>*, typename atomic<T>::value_type,
                               memory_order) noexcept;
  template<class T>
    T atomic_fetch_xor(volatile atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    T atomic_fetch_xor(atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    T atomic_fetch_xor_explicit(volatile atomic<T>*, typename atomic<T>::value_type,
                                memory_order) noexcept;
  template<class T>
    T atomic_fetch_xor_explicit(atomic<T>*, typename atomic<T>::value_type,
                                memory_order) noexcept;
  template<class T>
    T atomic_fetch_max(volatile atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    T atomic_fetch_max(atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    T atomic_fetch_max_explicit(volatile atomic<T>*, typename atomic<T>::value_type,
                                memory_order) noexcept;
  template<class T>
    T atomic_fetch_max_explicit(atomic<T>*, typename atomic<T>::value_type,
                                memory_order) noexcept;
  template<class T>
    T atomic_fetch_min(volatile atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    T atomic_fetch_min(atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    T atomic_fetch_min_explicit(volatile atomic<T>*, typename atomic<T>::value_type,
                                memory_order) noexcept;
  template<class T>
    T atomic_fetch_min_explicit(atomic<T>*, typename atomic<T>::value_type,
                                memory_order) noexcept;
 
  template<class T>
    void atomic_wait(const volatile atomic<T>*, typename atomic<T>::value_type);
  template<class T>
    void atomic_wait(const atomic<T>*, typename atomic<T>::value_type);
  template<class T>
    void atomic_wait_explicit(const volatile atomic<T>*,
                              typename atomic<T>::value_type, memory_order);
  template<class T>
    void atomic_wait_explicit(const atomic<T>*,
                              typename atomic<T>::value_type, memory_order);
  template<class T>
    void atomic_notify_one(volatile atomic<T>*);
  template<class T>
    void atomic_notify_one(atomic<T>*);
  template<class T>
    void atomic_notify_all(volatile atomic<T>*);
  template<class T>
    void atomic_notify_all(atomic<T>*);
 
  // type aliases
  using atomic_bool           = atomic<bool>;
  using atomic_char           = atomic<char>;
  using atomic_schar          = atomic<signed char>;
  using atomic_uchar          = atomic<unsigned char>;
  using atomic_short          = atomic<short>;
  using atomic_ushort         = atomic<unsigned short>;
  using atomic_int            = atomic<int>;
  using atomic_uint           = atomic<unsigned int>;
  using atomic_long           = atomic<long>;
  using atomic_ulong          = atomic<unsigned long>;
  using atomic_llong          = atomic<long long>;
  using atomic_ullong         = atomic<unsigned long long>;
  using atomic_char8_t        = atomic<char8_t>;
  using atomic_char16_t       = atomic<char16_t>;
  using atomic_char32_t       = atomic<char32_t>;
  using atomic_wchar_t        = atomic<wchar_t>;
 
  using atomic_int8_t         = atomic<int8_t>;
  using atomic_uint8_t        = atomic<uint8_t>;
  using atomic_int16_t        = atomic<int16_t>;
  using atomic_uint16_t       = atomic<uint16_t>;
  using atomic_int32_t        = atomic<int32_t>;
  using atomic_uint32_t       = atomic<uint32_t>;
  using atomic_int64_t        = atomic<int64_t>;
  using atomic_uint64_t       = atomic<uint64_t>;
 
  using atomic_int_least8_t   = atomic<int_least8_t>;
  using atomic_uint_least8_t  = atomic<uint_least8_t>;
  using atomic_int_least16_t  = atomic<int_least16_t>;
  using atomic_uint_least16_t = atomic<uint_least16_t>;
  using atomic_int_least32_t  = atomic<int_least32_t>;
  using atomic_uint_least32_t = atomic<uint_least32_t>;
  using atomic_int_least64_t  = atomic<int_least64_t>;
  using atomic_uint_least64_t = atomic<uint_least64_t>;
 
  using atomic_int_fast8_t    = atomic<int_fast8_t>;
  using atomic_uint_fast8_t   = atomic<uint_fast8_t>;
  using atomic_int_fast16_t   = atomic<int_fast16_t>;
  using atomic_uint_fast16_t  = atomic<uint_fast16_t>;
  using atomic_int_fast32_t   = atomic<int_fast32_t>;
  using atomic_uint_fast32_t  = atomic<uint_fast32_t>;
  using atomic_int_fast64_t   = atomic<int_fast64_t>;
  using atomic_uint_fast64_t  = atomic<uint_fast64_t>;
 
  using atomic_intptr_t       = atomic<intptr_t>;
  using atomic_uintptr_t      = atomic<uintptr_t>;
  using atomic_size_t         = atomic<size_t>;
  using atomic_ptrdiff_t      = atomic<ptrdiff_t>;
  using atomic_intmax_t       = atomic<intmax_t>;
  using atomic_uintmax_t      = atomic<uintmax_t>;
 
  using atomic_signed_lock_free   = /* see description */;
  using atomic_unsigned_lock_free = /* see description */;
 
  // flag type and operations
  struct atomic_flag;
 
  bool atomic_flag_test(const volatile atomic_flag*) noexcept;
  bool atomic_flag_test(const atomic_flag*) noexcept;
  bool atomic_flag_test_explicit(const volatile atomic_flag*, memory_order) noexcept;
  bool atomic_flag_test_explicit(const atomic_flag*, memory_order) noexcept;
  bool atomic_flag_test_and_set(volatile atomic_flag*) noexcept;
  bool atomic_flag_test_and_set(atomic_flag*) noexcept;
  bool atomic_flag_test_and_set_explicit(volatile atomic_flag*, memory_order) noexcept;
  bool atomic_flag_test_and_set_explicit(atomic_flag*, memory_order) noexcept;
  void atomic_flag_clear(volatile atomic_flag*) noexcept;
  void atomic_flag_clear(atomic_flag*) noexcept;
  void atomic_flag_clear_explicit(volatile atomic_flag*, memory_order) noexcept;
  void atomic_flag_clear_explicit(atomic_flag*, memory_order) noexcept;
 
  void atomic_flag_wait(const volatile atomic_flag*, bool) noexcept;
  void atomic_flag_wait(const atomic_flag*, bool) noexcept;
  void atomic_flag_wait_explicit(const volatile atomic_flag*,
                                 bool, memory_order) noexcept;
  void atomic_flag_wait_explicit(const atomic_flag*,
                                 bool, memory_order) noexcept;
  void atomic_flag_notify_one(volatile atomic_flag*) noexcept;
  void atomic_flag_notify_one(atomic_flag*) noexcept;
  void atomic_flag_notify_all(volatile atomic_flag*) noexcept;
  void atomic_flag_notify_all(atomic_flag*) noexcept;
 
  // fences
  extern "C" void atomic_thread_fence(memory_order) noexcept;
  extern "C" void atomic_signal_fence(memory_order) noexcept;
}
 
// deprecated
namespace std {
  template<class T>
    void atomic_init(volatile atomic<T>*, typename atomic<T>::value_type) noexcept;
  template<class T>
    void atomic_init(atomic<T>*, typename atomic<T>::value_type) noexcept;
 
  #define ATOMIC_VAR_INIT(value) /* see description */
 
  #define ATOMIC_FLAG_INIT /* see description */
}

[edit] Class template std::atomic

namespace std {
  template<class T> struct atomic {
    using value_type = T;
 
    static constexpr bool is_always_lock_free = /* implementation-defined */;
    bool is_lock_free() const volatile noexcept;
    bool is_lock_free() const noexcept;
 
    // operations on atomic types
    constexpr atomic() noexcept(is_nothrow_default_constructible_v<T>);
    constexpr atomic(T) noexcept;
    atomic(const atomic&) = delete;
    atomic& operator=(const atomic&) = delete;
    atomic& operator=(const atomic&) volatile = delete;
 
    T load(memory_order = memory_order::seq_cst) const volatile noexcept;
    T load(memory_order = memory_order::seq_cst) const noexcept;
    operator T() const volatile noexcept;
    operator T() const noexcept;
    void store(T, memory_order = memory_order::seq_cst) volatile noexcept;
    void store(T, memory_order = memory_order::seq_cst) noexcept;
    T operator=(T) volatile noexcept;
    T operator=(T) noexcept;
 
    T exchange(T, memory_order = memory_order::seq_cst) volatile noexcept;
    T exchange(T, memory_order = memory_order::seq_cst) noexcept;
    bool compare_exchange_weak(T&, T, memory_order, memory_order) volatile noexcept;
    bool compare_exchange_weak(T&, T, memory_order, memory_order) noexcept;
    bool compare_exchange_strong(T&, T, memory_order, memory_order) volatile noexcept;
    bool compare_exchange_strong(T&, T, memory_order, memory_order) noexcept;
    bool compare_exchange_weak(T&, T,
                               memory_order = memory_order::seq_cst) volatile noexcept;
    bool compare_exchange_weak(T&, T, memory_order = memory_order::seq_cst) noexcept;
    bool compare_exchange_strong(T&, T,
                                 memory_order = memory_order::seq_cst) volatile noexcept;
    bool compare_exchange_strong(T&, T, memory_order = memory_order::seq_cst) noexcept;
 
    void wait(T, memory_order = memory_order::seq_cst) const volatile noexcept;
    void wait(T, memory_order = memory_order::seq_cst) const noexcept;
    void notify_one() volatile noexcept;
    void notify_one() noexcept;
    void notify_all() volatile noexcept;
    void notify_all() noexcept;
  };
}

[edit] Specializations of std::atomic for integral types

namespace std {
  template<> struct atomic</* integral */> {
    using value_type = /* integral */;
    using difference_type = value_type;
 
    static constexpr bool is_always_lock_free = /* implementation-defined */;
    bool is_lock_free() const volatile noexcept;
    bool is_lock_free() const noexcept;
 
    constexpr atomic() noexcept;
    constexpr atomic(/* integral */) noexcept;
    atomic(const atomic&) = delete;
    atomic& operator=(const atomic&) = delete;
    atomic& operator=(const atomic&) volatile = delete;
 
    void store(/* integral */, memory_order = memory_order::seq_cst) volatile noexcept;
    void store(/* integral */, memory_order = memory_order::seq_cst) noexcept;
    /* integral */ operator=(/* integral */) volatile noexcept;
    /* integral */ operator=(/* integral */) noexcept;
    /* integral */ load(memory_order = memory_order::seq_cst) const volatile noexcept;
    /* integral */ load(memory_order = memory_order::seq_cst) const noexcept;
    operator /* integral */() const volatile noexcept;
    operator /* integral */() const noexcept;
 
    /* integral */ exchange(/* integral */,
                        memory_order = memory_order::seq_cst) volatile noexcept;
    /* integral */ exchange(/* integral */,
                        memory_order = memory_order::seq_cst) noexcept;
    bool compare_exchange_weak(/* integral */&, /* integral */,
                               memory_order, memory_order) volatile noexcept;
    bool compare_exchange_weak(/* integral */&, /* integral */,
                               memory_order, memory_order) noexcept;
    bool compare_exchange_strong(/* integral */&, /* integral */,
                                 memory_order, memory_order) volatile noexcept;
    bool compare_exchange_strong(/* integral */&, /* integral */,
                                 memory_order, memory_order) noexcept;
    bool compare_exchange_weak(/* integral */&, /* integral */,
                               memory_order = memory_order::seq_cst) volatile noexcept;
    bool compare_exchange_weak(/* integral */&, /* integral */,
                               memory_order = memory_order::seq_cst) noexcept;
    bool compare_exchange_strong(/* integral */&, /* integral */,
                                 memory_order = memory_order::seq_cst) volatile noexcept;
    bool compare_exchange_strong(/* integral */&, /* integral */,
                                 memory_order = memory_order::seq_cst) noexcept;
 
    /* integral */ fetch_add(/* integral */,
                         memory_order = memory_order::seq_cst) volatile noexcept;
    /* integral */ fetch_add(/* integral */,
                         memory_order = memory_order::seq_cst) noexcept;
    /* integral */ fetch_sub(/* integral */,
                         memory_order = memory_order::seq_cst) volatile noexcept;
    /* integral */ fetch_sub(/* integral */,
                         memory_order = memory_order::seq_cst) noexcept;
    /* integral */ fetch_and(/* integral */,
                         memory_order = memory_order::seq_cst) volatile noexcept;
    /* integral */ fetch_and(/* integral */,
                         memory_order = memory_order::seq_cst) noexcept;
    /* integral */ fetch_or(/* integral */,
                         memory_order = memory_order::seq_cst) volatile noexcept;
    /* integral */ fetch_or(/* integral */,
                         memory_order = memory_order::seq_cst) noexcept;
    /* integral */ fetch_xor(/* integral */,
                         memory_order = memory_order::seq_cst) volatile noexcept;
    /* integral */ fetch_xor(/* integral */,
                         memory_order = memory_order::seq_cst) noexcept;
    /* integral */ fetch_max(/* integral */,
                         memory_order = memory_order::seq_cst) volatile noexcept;
    /* integral */ fetch_max(/* integral */,
                         memory_order = memory_order::seq_cst) noexcept;
    /* integral */ fetch_min(/* integral */,
                         memory_order = memory_order::seq_cst) volatile noexcept;
    /* integral */ fetch_min(/* integral */,
                         memory_order = memory_order::seq_cst) noexcept;
 
    /* integral */ operator++(int) volatile noexcept;
    /* integral */ operator++(int) noexcept;
    /* integral */ operator--(int) volatile noexcept;
    /* integral */ operator--(int) noexcept;
    /* integral */ operator++() volatile noexcept;
    /* integral */ operator++() noexcept;
    /* integral */ operator--() volatile noexcept;
    /* integral */ operator--() noexcept;
    /* integral */ operator+=(/* integral */) volatile noexcept;
    /* integral */ operator+=(/* integral */) noexcept;
    /* integral */ operator-=(/* integral */) volatile noexcept;
    /* integral */ operator-=(/* integral */) noexcept;
    /* integral */ operator&=(/* integral */) volatile noexcept;
    /* integral */ operator&=(/* integral */) noexcept;
    /* integral */ operator|=(/* integral */) volatile noexcept;
    /* integral */ operator|=(/* integral */) noexcept;
    /* integral */ operator^=(/* integral */) volatile noexcept;
    /* integral */ operator^=(/* integral */) noexcept;
 
    void wait(/* integral */,
              memory_order = memory_order::seq_cst) const volatile noexcept;
    void wait(/* integral */, memory_order = memory_order::seq_cst) const noexcept;
    void notify_one() volatile noexcept;
    void notify_one() noexcept;
    void notify_all() volatile noexcept;
    void notify_all() noexcept;
  };
}

[edit] Specializations of std::atomic for floating-point types

namespace std {
  template<> struct atomic</* floating-point */> {
    using value_type = /* floating-point */;
    using difference_type = value_type;
 
    static constexpr bool is_always_lock_free = /* implementation-defined */;
    bool is_lock_free() const volatile noexcept;
    bool is_lock_free() const noexcept;
 
    constexpr atomic() noexcept;
    constexpr atomic(/* floating-point */) noexcept;
    atomic(const atomic&) = delete;
    atomic& operator=(const atomic&) = delete;
    atomic& operator=(const atomic&) volatile = delete;
 
    void store(/* floating-point */,
               memory_order = memory_order_seq_cst) volatile noexcept;
    void store(/* floating-point */,
               memory_order = memory_order_seq_cst) noexcept;
    /* floating-point */ operator=(/* floating-point */) volatile noexcept;
    /* floating-point */ operator=(/* floating-point */) noexcept;
    /* floating-point */ load(memory_order = memory_order_seq_cst) volatile noexcept;
    /* floating-point */ load(memory_order = memory_order_seq_cst) noexcept;
    operator /* floating-point */() volatile noexcept;
    operator /* floating-point */() noexcept;
 
    /* floating-point */ exchange(/* floating-point */,
                            memory_order = memory_order_seq_cst) volatile noexcept;
    /* floating-point */ exchange(/* floating-point */,
                            memory_order = memory_order_seq_cst) noexcept;
    bool compare_exchange_weak(/* floating-point */&, /* floating-point */,
                               memory_order, memory_order) volatile noexcept;
    bool compare_exchange_weak(/* floating-point */&, /* floating-point */,
                               memory_order, memory_order) noexcept;
    bool compare_exchange_strong(/* floating-point */&, /* floating-point */,
                                 memory_order, memory_order) volatile noexcept;
    bool compare_exchange_strong(/* floating-point */&, /* floating-point */,
                                 memory_order, memory_order) noexcept;
    bool compare_exchange_weak(/* floating-point */&, /* floating-point */,
                               memory_order = memory_order_seq_cst) volatile noexcept;
    bool compare_exchange_weak(/* floating-point */&, /* floating-point */,
                               memory_order = memory_order_seq_cst) noexcept;
    bool compare_exchange_strong(/* floating-point */&, /* floating-point */,
                                 memory_order = memory_order_seq_cst) volatile noexcept;
    bool compare_exchange_strong(/* floating-point */&, /* floating-point */,
                                 memory_order = memory_order_seq_cst) noexcept;
 
    /* floating-point */ fetch_add(/* floating-point */,
                             memory_order = memory_order_seq_cst) volatile noexcept;
    /* floating-point */ fetch_add(/* floating-point */,
                             memory_order = memory_order_seq_cst) noexcept;
    /* floating-point */ fetch_sub(/* floating-point */,
                             memory_order = memory_order_seq_cst) volatile noexcept;
    /* floating-point */ fetch_sub(/* floating-point */,
                             memory_order = memory_order_seq_cst) noexcept;
 
    /* floating-point */ operator+=(/* floating-point */) volatile noexcept;
    /* floating-point */ operator+=(/* floating-point */) noexcept;
    /* floating-point */ operator-=(/* floating-point */) volatile noexcept;
    /* floating-point */ operator-=(/* floating-point */) noexcept;
 
    void wait(/* floating-point */,
              memory_order = memory_order::seq_cst) const volatile noexcept;
    void wait(/* floating-point */,
              memory_order = memory_order::seq_cst) const noexcept;
    void notify_one() volatile noexcept;
    void notify_one() noexcept;
    void notify_all() volatile noexcept;
    void notify_all() noexcept;
  };
}

[edit] Specializations of std::atomic for pointer types

namespace std {
  template<class T> struct atomic<T*> {
    using value_type = T*;
    using difference_type = ptrdiff_t;
 
    static constexpr bool is_always_lock_free = /* implementation-defined */;
    bool is_lock_free() const volatile noexcept;
    bool is_lock_free() const noexcept;
 
    constexpr atomic() noexcept;
    constexpr atomic(T*) noexcept;
    atomic(const atomic&) = delete;
    atomic& operator=(const atomic&) = delete;
    atomic& operator=(const atomic&) volatile = delete;
 
    void store(T*, memory_order = memory_order::seq_cst) volatile noexcept;
    void store(T*, memory_order = memory_order::seq_cst) noexcept;
    T* operator=(T*) volatile noexcept;
    T* operator=(T*) noexcept;
    T* load(memory_order = memory_order::seq_cst) const volatile noexcept;
    T* load(memory_order = memory_order::seq_cst) const noexcept;
    operator T*() const volatile noexcept;
    operator T*() const noexcept;
 
    T* exchange(T*, memory_order = memory_order::seq_cst) volatile noexcept;
    T* exchange(T*, memory_order = memory_order::seq_cst) noexcept;
    bool compare_exchange_weak(T*&, T*, memory_order, memory_order) volatile noexcept;
    bool compare_exchange_weak(T*&, T*, memory_order, memory_order) noexcept;
    bool compare_exchange_strong(T*&, T*, memory_order, memory_order) volatile noexcept;
    bool compare_exchange_strong(T*&, T*, memory_order, memory_order) noexcept;
    bool compare_exchange_weak(T*&, T*,
                               memory_order = memory_order::seq_cst) volatile noexcept;
    bool compare_exchange_weak(T*&, T*,
                               memory_order = memory_order::seq_cst) noexcept;
    bool compare_exchange_strong(T*&, T*,
                                 memory_order = memory_order::seq_cst) volatile noexcept;
    bool compare_exchange_strong(T*&, T*,
                                 memory_order = memory_order::seq_cst) noexcept;
 
    T* fetch_add(ptrdiff_t, memory_order = memory_order::seq_cst) volatile noexcept;
    T* fetch_add(ptrdiff_t, memory_order = memory_order::seq_cst) noexcept;
    T* fetch_sub(ptrdiff_t, memory_order = memory_order::seq_cst) volatile noexcept;
    T* fetch_sub(ptrdiff_t, memory_order = memory_order::seq_cst) noexcept;
    T* fetch_max(T*, memory_order = memory_order::seq_cst) volatile noexcept;
    T* fetch_max(T*, memory_order = memory_order::seq_cst) noexcept;
    T* fetch_min(T*, memory_order = memory_order::seq_cst) volatile noexcept;
    T* fetch_min(T*, memory_order = memory_order::seq_cst) noexcept;
 
    T* operator++(int) volatile noexcept;
    T* operator++(int) noexcept;
    T* operator--(int) volatile noexcept;
    T* operator--(int) noexcept;
    T* operator++() volatile noexcept;
    T* operator++() noexcept;
    T* operator--() volatile noexcept;
    T* operator--() noexcept;
    T* operator+=(ptrdiff_t) volatile noexcept;
    T* operator+=(ptrdiff_t) noexcept;
    T* operator-=(ptrdiff_t) volatile noexcept;
    T* operator-=(ptrdiff_t) noexcept;
 
    void wait(T*, memory_order = memory_order::seq_cst) const volatile noexcept;
    void wait(T*, memory_order = memory_order::seq_cst) const noexcept;
    void notify_one() volatile noexcept;
    void notify_one() noexcept;
    void notify_all() volatile noexcept;
    void notify_all() noexcept;
  };
}

[edit] Class template std::atomic_ref

namespace std {
  template<class T> struct atomic_ref {
  private:
    T* ptr;             // exposition only
  public:
    using value_type = T;
    static constexpr size_t required_alignment = /* implementation-defined */;
 
    static constexpr bool is_always_lock_free = /* implementation-defined */;
    bool is_lock_free() const noexcept;
 
    explicit atomic_ref(T&);
    atomic_ref(const atomic_ref&) noexcept;
    atomic_ref& operator=(const atomic_ref&) = delete;
 
    void store(T, memory_order = memory_order_seq_cst) const noexcept;
    T operator=(T) const noexcept;
    T load(memory_order = memory_order_seq_cst) const noexcept;
    operator T() const noexcept;
 
    T exchange(T, memory_order = memory_order_seq_cst) const noexcept;
    bool compare_exchange_weak(T&, T,
                               memory_order, memory_order) const noexcept;
    bool compare_exchange_strong(T&, T,
                                 memory_order, memory_order) const noexcept;
    bool compare_exchange_weak(T&, T,
                               memory_order = memory_order_seq_cst) const noexcept;
    bool compare_exchange_strong(T&, T,
                                 memory_order = memory_order_seq_cst) const noexcept;
 
    void wait(T, memory_order = memory_order::seq_cst) const noexcept;
    void notify_one() const noexcept;
    void notify_all() const noexcept;
  };
}

[edit] Specializations of std::atomic_ref for integral types

namespace std {
  template<> struct atomic_ref</* integral */> {
  private:
    /* integral */* ptr;        // exposition only
  public:
    using value_type = /* integral */;
    using difference_type = value_type;
    static constexpr size_t required_alignment = /* implementation-defined */;
 
    static constexpr bool is_always_lock_free = /* implementation-defined */;
    bool is_lock_free() const noexcept;
 
    explicit atomic_ref(/* integral */&);
    atomic_ref(const atomic_ref&) noexcept;
    atomic_ref& operator=(const atomic_ref&) = delete;
 
    void store(/* integral */, memory_order = memory_order_seq_cst) const noexcept;
    /* integral */ operator=(/* integral */) const noexcept;
    /* integral */ load(memory_order = memory_order_seq_cst) const noexcept;
    operator /* integral */() const noexcept;
 
    /* integral */ exchange(/* integral */,
                      memory_order = memory_order_seq_cst) const noexcept;
    bool compare_exchange_weak(/* integral */&, /* integral */,
                               memory_order, memory_order) const noexcept;
    bool compare_exchange_strong(/* integral */&, /* integral */,
                                 memory_order, memory_order) const noexcept;
    bool compare_exchange_weak(/* integral */&, /* integral */,
                               memory_order = memory_order_seq_cst) const noexcept;
    bool compare_exchange_strong(/* integral */&, /* integral */,
                                 memory_order = memory_order_seq_cst) const noexcept;
 
    /* integral */ fetch_add(/* integral */,
                       memory_order = memory_order_seq_cst) const noexcept;
    /* integral */ fetch_sub(/* integral */,
                       memory_order = memory_order_seq_cst) const noexcept;
    /* integral */ fetch_and(/* integral */,
                       memory_order = memory_order_seq_cst) const noexcept;
    /* integral */ fetch_or(/* integral */,
                      memory_order = memory_order_seq_cst) const noexcept;
    /* integral */ fetch_xor(/* integral */,
                       memory_order = memory_order_seq_cst) const noexcept;
    /* integral */ fetch_max(/* integral */,
                       memory_order = memory_order_seq_cst) const noexcept;
    /* integral */ fetch_min(/* integral */,
                       memory_order = memory_order_seq_cst) const noexcept;
 
    /* integral */ operator++(int) const noexcept;
    /* integral */ operator--(int) const noexcept;
    /* integral */ operator++() const noexcept;
    /* integral */ operator--() const noexcept;
    /* integral */ operator+=(/* integral */) const noexcept;
    /* integral */ operator-=(/* integral */) const noexcept;
    /* integral */ operator&=(/* integral */) const noexcept;
    /* integral */ operator

[edit] Specializations of std::atomic_ref for floating-point types

namespace std {
  template<> struct atomic_ref</* floating-point */> {
  private:
    /* floating-point */* ptr;  // exposition only
  public:
    using value_type = /* floating-point */;
    using difference_type = value_type;
    static constexpr size_t required_alignment = /* implementation-defined */;
 
    static constexpr bool is_always_lock_free = /* implementation-defined */;
    bool is_lock_free() const noexcept;
 
    explicit atomic_ref(/* floating-point */&);
    atomic_ref(const atomic_ref&) noexcept;
    atomic_ref& operator=(const atomic_ref&) = delete;
 
    void store(/* floating-point */, memory_order = memory_order_seq_cst) const noexcept;
    /* floating-point */ operator=(/* floating-point */) const noexcept;
    /* floating-point */ load(memory_order = memory_order_seq_cst) const noexcept;
    operator /* floating-point */() const noexcept;
 
    /* floating-point */ exchange(/* floating-point */,
                            memory_order = memory_order_seq_cst) const noexcept;
    bool compare_exchange_weak(/* floating-point */&, /* floating-point */,
                               memory_order, memory_order) const noexcept;
    bool compare_exchange_strong(/* floating-point */&, /* floating-point */,
                                 memory_order, memory_order) const noexcept;
    bool compare_exchange_weak(/* floating-point */&, /* floating-point */,
                               memory_order = memory_order_seq_cst) const noexcept;
    bool compare_exchange_strong(/* floating-point */&, /* floating-point */,
                                 memory_order = memory_order_seq_cst) const noexcept;
 
    /* floating-point */ fetch_add(/* floating-point */,
                             memory_order = memory_order_seq_cst) const noexcept;
    /* floating-point */ fetch_sub(/* floating-point */,
                             memory_order = memory_order_seq_cst) const noexcept;
 
    /* floating-point */ operator+=(/* floating-point */) const noexcept;
    /* floating-point */ operator-=(/* floating-point */) const noexcept;
 
    void wait(/* floating-point */, memory_order = memory_order::seq_cst) const noexcept;
    void notify_one() const noexcept;
    void notify_all() const noexcept;
  };
}

[edit] Specializations of std::atomic_ref for pointer types

namespace std {
  template<class T> struct atomic_ref<T*> {
  private:
    T** ptr;        // exposition only
  public:
    using value_type = T*;
    using difference_type = ptrdiff_t;
    static constexpr size_t required_alignment = /* implementation-defined */;
 
    static constexpr bool is_always_lock_free = /* implementation-defined */;
    bool is_lock_free() const noexcept;
 
    explicit atomic_ref(T*&);
    atomic_ref(const atomic_ref&) noexcept;
    atomic_ref& operator=(const atomic_ref&) = delete;
 
    void store(T*, memory_order = memory_order_seq_cst) const noexcept;
    T* operator=(T*) const noexcept;
    T* load(memory_order = memory_order_seq_cst) const noexcept;
    operator T*() const noexcept;
 
    T* exchange(T*, memory_order = memory_order_seq_cst) const noexcept;
    bool compare_exchange_weak(T*&, T*,
                               memory_order, memory_order) const noexcept;
    bool compare_exchange_strong(T*&, T*,
                                 memory_order, memory_order) const noexcept;
    bool compare_exchange_weak(T*&, T*,
                               memory_order = memory_order_seq_cst) const noexcept;
    bool compare_exchange_strong(T*&, T*,
                                 memory_order = memory_order_seq_cst) const noexcept;
 
    T* fetch_add(difference_type, memory_order = memory_order_seq_cst) const noexcept;
    T* fetch_sub(difference_type, memory_order = memory_order_seq_cst) const noexcept;
    T* fetch_max(T *, memory_order = memory_order::seq_cst) const noexcept;
    T* fetch_min(T *, memory_order = memory_order::seq_cst) const noexcept;
 
    T* operator++(int) const noexcept;
    T* operator--(int) const noexcept;
    T* operator++() const noexcept;
    T* operator--() const noexcept;
    T* operator+=(difference_type) const noexcept;
    T* operator-=(difference_type) const noexcept;
 
    void wait(T*, memory_order = memory_order::seq_cst) const noexcept;
    void notify_one() const noexcept;
    void notify_all() const noexcept;
  };
}

[edit] Class std::atomic_flag

namespace std {
  struct atomic_flag {
    constexpr atomic_flag() noexcept;
    atomic_flag(const atomic_flag&) = delete;
    atomic_flag& operator=(const atomic_flag&) = delete;
    atomic_flag& operator=(const atomic_flag&) volatile = delete;
 
    bool test(memory_order = memory_order::seq_cst) const volatile noexcept;
    bool test(memory_order = memory_order::seq_cst) const noexcept;
    bool test_and_set(memory_order = memory_order::seq_cst) volatile noexcept;
    bool test_and_set(memory_order = memory_order::seq_cst) noexcept;
    void clear(memory_order = memory_order::seq_cst) volatile noexcept;
    void clear(memory_order = memory_order::seq_cst) noexcept;
 
    void wait(bool, memory_order = memory_order::seq_cst) const volatile noexcept;
    void wait(bool, memory_order = memory_order::seq_cst) const noexcept;
    void notify_one() volatile noexcept;
    void notify_one() noexcept;
    void notify_all() volatile noexcept;
    void notify_all() noexcept;
  };
}