diff --git a/include/cereal/details/static_object.hpp b/include/cereal/details/static_object.hpp index 658d1b1bf..c9c888d7d 100644 --- a/include/cereal/details/static_object.hpp +++ b/include/cereal/details/static_object.hpp @@ -109,6 +109,7 @@ namespace cereal static LockGuard lock() { #if CEREAL_THREAD_SAFE + static std::mutex instanceMutex; return LockGuard{instanceMutex}; #else return LockGuard{}; @@ -117,15 +118,9 @@ namespace cereal private: static T & instance; - #if CEREAL_THREAD_SAFE - static std::mutex instanceMutex; - #endif }; template T & StaticObject::instance = StaticObject::create(); - #if CEREAL_THREAD_SAFE - template std::mutex StaticObject::instanceMutex; - #endif } // namespace detail } // namespace cereal