22#include "util/Concepts.hpp"
32template <SomeNumberType NumberType>
35 using ValueType = NumberType;
54 operator=(
Atomic const&) =
delete;
56 operator=(
Atomic&&) =
delete;
66 if constexpr (std::is_integral_v<ValueType>) {
67 value_.fetch_add(
value);
69#if __cpp_lib_atomic_float >= 201711L
70 value_.fetch_add(
value);
74 auto current = value_.load();
75 while (!value_.compare_exchange_weak(current, current +
value)) {
104 std::atomic<ValueType> value_{0};
107template <SomeNumberType NumberType>
108using AtomicPtr = std::unique_ptr<Atomic<NumberType>>;
Atomic wrapper for integral and floating point types.
Definition Atomic.hpp:33
void set(ValueType const value)
Update the current value to the new value.
Definition Atomic.hpp:87
void add(ValueType const value)
Add a value to the current value.
Definition Atomic.hpp:64
ValueType value() const
Get the current value.
Definition Atomic.hpp:98
Atomic(ValueType const value)
Construct a new Atomic object.
Definition Atomic.hpp:44
This namespace contains various utilities.
Definition AccountUtils.hpp:30