#pragma once #include namespace utilities::concurrency { template class container { public: template R access(F&& accessor) const { std::lock_guard _{mutex_}; return accessor(object_); } template R access(F&& accessor) { std::lock_guard _{mutex_}; return accessor(object_); } template R access_with_lock(F&& accessor) const { std::unique_lock lock{mutex_}; return accessor(object_, lock); } template R access_with_lock(F&& accessor) { std::unique_lock lock{mutex_}; return accessor(object_, lock); } T& get_raw() { return object_; } const T& get_raw() const { return object_; } private: mutable MutexType mutex_{}; T object_{}; }; }