#pragma once #include #include template class atomic_shared_ptr final { public: atomic_shared_ptr(std::shared_ptr&& ptr) : ptr(ptr) {} std::shared_ptr load() { return std::move(std::atomic_load(&ptr)); } bool compare_exchange_weak(std::shared_ptr& expected, std::shared_ptr desired) { return atomic_compare_exchange_weak(&ptr, &expected, desired); } private: std::shared_ptr ptr; };