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...
Ask