Documentation Home >> Headers >> <atomic> Header >> std::atomic >> specializations >> std::atomic<T*> partial specialization

The std::atomic<T*> partial specialization of the std::atomic class template provides an atomic data type for each pointer type, with a comprehensive set of operations.

Instances of these std::atomic<T*> are not CopyConstructible or CopyAssignable, as these operations cannot be performed as a single atomic operation.

template<typename T>
struct atomic<T*>
{
    atomic() = default;
    constexpr atomic(T*);
    bool operator=(T*) volatile;

    atomic(const atomic&) = delete;
    atomic& operator=(const atomic&) = delete;

    bool is_lock_free() const volatile;
    void store(
        T*,memory_order = memory_order_seq_cst)
        volatile;
    T* load(
        memory_order = memory_order_seq_cst)
        const volatile;
    T* exchange(
        T*,memory_order = memory_order_seq_cst)
        volatile;

    bool compare_exchange_strong(
        T* & old_value, T* new_value,
        memory_order order = memory_order_seq_cst)
        volatile;
    bool compare_exchange_strong(
        T* & old_value, T* new_value,
        memory_order success_order,
        memory_order failure_order) volatile;
    bool compare_exchange_weak(
        T* & old_value, T* new_value,
        memory_order order = memory_order_seq_cst)
        volatile;
    bool compare_exchange_weak(
        T* & old_value, T* new_value,
        memory_order success_order,
        memory_order failure_order) volatile;

    operator T*() const volatile;

    T* fetch_add(
        ptrdiff_t,
        memory_order = memory_order_seq_cst) volatile;
    T* fetch_sub(
        ptrdiff_t,
        memory_order = memory_order_seq_cst) volatile;

    T* operator++() volatile;
    T* operator++(int) volatile;
    T* operator--() volatile;
    T* operator--(int) volatile;

    T* operator+=(ptrdiff_t) volatile;
    T* operator-=(ptrdiff_t) volatile;
};

bool atomic_is_lock_free(
    volatile const atomic<T*>*);
void atomic_init(
    volatile atomic<T*>*, T*);
T* atomic_exchange(
    volatile atomic<T*>*, T*);
T* atomic_exchange_explicit(
    volatile atomic<T*>*, T*, memory_order);
void atomic_store(
    volatile atomic<T*>*, T*);
void atomic_store_explicit(
    volatile atomic<T*>*, T*, memory_order);
T* atomic_load(
    volatile const atomic<T*>*);
T* atomic_load_explicit(
    volatile const atomic<T*>*, memory_order);
bool atomic_compare_exchange_strong(
    volatile atomic<T*>*,T* * old_value,
     T* new_value);
bool atomic_compare_exchange_strong_explicit(
    volatile atomic<T*>*,T* * old_value,
     T* new_value, memory_order success_order,
     memory_order failure_order);
bool atomic_compare_exchange_weak(
    volatile atomic<T*>*,T* * old_value,
     T* new_value);
bool atomic_compare_exchange_weak_explicit(
    volatile atomic<T*>*,T* * old_value, T* new_value,
     memory_order success_order,
     memory_order failure_order);

T* atomic_fetch_add(
    volatile atomic<T*>*, ptrdiff_t);
T* atomic_fetch_add_explicit(
    volatile atomic<T*>*, ptrdiff_t, memory_order);
T* atomic_fetch_sub(
    volatile atomic<T*>*, ptrdiff_t);
T* atomic_fetch_sub_explicit(
    volatile atomic<T*>*, ptrdiff_t, memory_order);
Header

#include <atomic>

See Also