From f927a914dd0ee22b6a318d37d57903ad3591f7d7 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Tue, 28 May 2024 11:38:21 -0500 Subject: [PATCH] feat: add `Singleton` class to `REX` --- CommonLibF4/include/REX/REX.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CommonLibF4/include/REX/REX.h b/CommonLibF4/include/REX/REX.h index 9bdc966f..b7b8aa04 100644 --- a/CommonLibF4/include/REX/REX.h +++ b/CommonLibF4/include/REX/REX.h @@ -167,3 +167,27 @@ namespace REX std::underlying_type_t< std::common_type_t>>; } + +namespace REX +{ + template + class Singleton + { + public: + static T* GetSingleton() + { + static T singleton; + return std::addressof(singleton); + } + + protected: + Singleton() = default; + ~Singleton() = default; + + Singleton(const Singleton&) = delete; + Singleton(Singleton&&) = delete; + + Singleton& operator=(const Singleton&) = delete; + Singleton& operator=(Singleton&&) = delete; + }; +}