27 namespace AtomicHelpers
29 template <
typename T>
struct DiffTypeHelper {
using Type = T; };
30 template <
typename T>
struct DiffTypeHelper<T*> {
using Type = std::ptrdiff_t; };
40template <
typename Type>
43 using DiffType =
typename AtomicHelpers::DiffTypeHelper<Type>::Type;
57 #if __cpp_lib_atomic_is_always_lock_free
58 static_assert (std::atomic<Type>::is_always_lock_free,
59 "This class can only be used for lock-free types");
67 void set (Type newValue)
noexcept {
value = newValue; }
70 Type
exchange (Type newValue)
noexcept {
return value.exchange (newValue); }
Type get() const noexcept
Type exchange(Type newValue) noexcept
Atomic(Type initialValue) noexcept
void set(Type newValue) noexcept
std::atomic< Type > value
bool compareAndSetBool(Type newValue, Type valueToCompare) noexcept
Atomic< Type > & operator=(const Atomic &other) noexcept
Type operator--() noexcept
Type operator-=(DiffType amountToSubtract) noexcept
Type operator+=(DiffType amountToAdd) noexcept
void memoryBarrier() noexcept
Type operator++() noexcept
Atomic(const Atomic &other) noexcept