#pragma once #include #include namespace prometheus { template inline std::atomic& atomic_add_for_floating_types(std::atomic& value, const FloatingType& add) { FloatingType desired; FloatingType expected = value.load(std::memory_order_relaxed); do { desired = expected + add; } while (!value.compare_exchange_weak(expected, desired)); return value; } template ::value, int>::type> inline std::atomic& operator++(std::atomic& value) { return atomic_add_for_floating_types(value, 1.0); } template ::value, int>::type> inline std::atomic& operator+=(std::atomic& value, const FloatingType& val) { return atomic_add_for_floating_types(value, val); } template ::value, int>::type> inline std::atomic& operator--(std::atomic& value) { return atomic_add_for_floating_types(value, -1.0); } template ::value, int>::type> inline std::atomic& operator-=(std::atomic& value, const FloatingType& val) { return atomic_add_for_floating_types(value, -val); } }