Documentation Home >> Headers >> <atomic> Header >> std::atomic >> specializations >> std::atomic<integral-type> specializations

The std::atomic<integral-type> specializations of the std::atomic class template provides an atomic integral data type for each fundamental integer type, with a comprehensive set of operations.

The following specializations are provided:

std::atomic<char>
std::atomic<signed char>
std::atomic<unsigned char>
std::atomic<short>
std::atomic<unsigned short>
std::atomic<int>
std::atomic<unsigned>
std::atomic<long>
std::atomic<unsigned long>
std::atomic<long long>
std::atomic<unsigned long long>
std::atomic<wchar_t>
std::atomic<char16_t>
std::atomic<char32_t>
[Note] Note

Microsoft Visual Studio 2005/2008 specific: long long is not available under that name with this compiler. The 64-bit integral type is __int64, with the corresponding unsigned type being unsigned __int64.

Instances of these specializations are not CopyConstructible or CopyAssignable, as these operations cannot be performed as a single atomic operation.

template<>
struct atomic<integral-type>
{
    atomic() = default;
    constexpr atomic(integral-type);
    bool operator=(integral-type) volatile;

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

    bool is_lock_free() const volatile;
    void store(
        integral-type,
        memory_order = memory_order_seq_cst) volatile;
    integral-type load(
        memory_order = memory_order_seq_cst)
        const volatile;
    integral-type exchange(
        integral-type,
        memory_order = memory_order_seq_cst) volatile;

    bool compare_exchange_strong(
        integral-type & old_value,
        integral-type new_value,
         memory_order order = memory_order_seq_cst)
         volatile;
    bool compare_exchange_strong(
        integral-type & old_value,
        integral-type new_value,
        memory_order success_order,
        memory_order failure_order) volatile;
    bool compare_exchange_weak(
        integral-type & old_value,
        integral-type new_value,
        memory_order order = memory_order_seq_cst)
        volatile;
    bool compare_exchange_weak(
        integral-type & old_value,
        integral-type new_value,
        memory_order success_order,
        memory_order failure_order) volatile;

    operator integral-type() const volatile;

    integral-type fetch_add(
        integral-type,
        memory_order = memory_order_seq_cst) volatile;
    integral-type fetch_sub(
        integral-type,
        memory_order = memory_order_seq_cst) volatile;
    integral-type fetch_and(
        integral-type,
        memory_order = memory_order_seq_cst) volatile;
    integral-type fetch_or(
        integral-type,
        memory_order = memory_order_seq_cst) volatile;
    integral-type fetch_xor(
        integral-type,
        memory_order = memory_order_seq_cst) volatile;

    integral-type operator++() volatile;
    integral-type operator++(int) volatile;
    integral-type operator--() volatile;
    integral-type operator--(int) volatile;

    integral-type operator+=(
        integral-type) volatile;
    integral-type operator-=(
        integral-type) volatile;
    integral-type operator&=(
        integral-type) volatile;
    integral-type operator|=(
        integral-type) volatile;
    integral-type operator^=(
        integral-type) volatile;

};

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

integral-type atomic_fetch_add(
    volatile atomic<integral-type>*,
    integral-type);
integral-type atomic_fetch_add_explicit(
    volatile atomic<integral-type>*,
    integral-type, memory_order);
integral-type atomic_fetch_sub(
    volatile atomic<integral-type>*,
    integral-type);
integral-type atomic_fetch_sub_explicit(
    volatile atomic<integral-type>*,
    integral-type, memory_order);
integral-type atomic_fetch_and(
    volatile atomic<integral-type>*,
     integral-type);
integral-type atomic_fetch_and_explicit(
    volatile atomic<integral-type>*,
     integral-type, memory_order);
integral-type atomic_fetch_or(
    volatile atomic<integral-type>*,
     integral-type);
integral-type atomic_fetch_or_explicit(
    volatile atomic<integral-type>*,
     integral-type, memory_order);
integral-type atomic_fetch_xor(
    volatile atomic<integral-type>*,
     integral-type);
integral-type atomic_fetch_xor_explicit(
    volatile atomic<integral-type>*,
     integral-type, memory_order);
Header

#include <atomic>

See Also