There are specializations of the atomic_ref class template
for the integral types
char,
signed char,
unsigned char,
short,
unsigned short,
int,
unsigned int,
long,
unsigned long,
long long,
unsigned long long,
char8_t,
char16_t,
char32_t,
wchar_t,
and any other types needed by the typedefs in the header <cstdint>.

For each such type integral,
the specialization atomic_ref<integral> provides
additional atomic operations appropriate to 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 bool is_always_lock_free = implementation-defined; static constexpr size_t required_alignment = implementation-defined; atomic_ref& operator=(const atomic_ref&) = delete; explicit atomic_ref(integral&); atomic_ref(const atomic_ref&) noexcept; integral operator=(integral) const noexcept; operator integral() const noexcept; bool is_lock_free() const noexcept; void store(integral, memory_order = memory_order_seq_cst) const noexcept; integral load(memory_order = memory_order_seq_cst) 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 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|=(integral) const noexcept; integral operator^=(integral) const noexcept; }; }

The following operations perform arithmetic computations.

The key, operator, and computation correspondence is identified
in [tab:atomic.arithmetic.computations]Table *tab:atomic.arithmetic.computations.

```
integral fetch_key(integral operand, memory_order order = memory_order_seq_cst) const noexcept;
```

Effects: Atomically replaces the value referenced by *ptr with
the result of the computation applied to the value referenced by *ptr
and the given operand.

Memory is affected according to the value of order.

These operations are atomic read-modify-write operations ([intro.races]).

Remarks: For signed integer types,
the result is as if the object value and parameters
were converted to their corresponding unsigned types,
the computation performed on those types, and
the result converted back to the signed type.

```
integral operator op=(integral operand) const noexcept;
```