#pragma once #include #include template ::value>::type* = nullptr> class AtomicCounter { public: AtomicCounter(T initial = 0) : counter(initial) {} T next(std::memory_order order = std::memory_order_seq_cst) { return counter.fetch_add(1, order); } T operator++() { return next(); } private: std::atomic counter; };