Specializations of std::atomic_ref
Explore specializations associated with std::atomic_ref.
We'll cover the following...
You can specialize std::atomic_ref for user-defined types, use partial specializations for pointer
types, or full specializations for arithmetic types such as integral or floating-point types.
Primary template
The primary template std::atomic_ref can be instantiated with a TriviallyCopyable type T as:
struct Counters {
int a;
int b;
};
Counter counter;
std::atomic_ref<Counters> cnt(counter);
Partial specializations for pointer types
The standard provides partial specializations for a pointer type: std::atomic_ref<T*>.
Specializations for arithmetic types
The standard provides specialization for the integral and floating-point types: std::atomic_ref<arithmetic type>.
-
Character types:
char,char8_t(C++20),char16_t,char32_t, andwchar_t -
Standard signed-integer types:
signed char,short,int,long, andlong long -
Standard unsigned-integer types:
unsigned char,unsigned short,unsigned int,unsigned long, andunsigned long long -
Additional integer types, defined in the header
cstdint :int8_t,int16_t,int32_t, andint64_t(signed integer with exactly , , , and bits)uint8_t,uint16_t,uint32_t, anduint64_t(unsigned integer with exactly