Skip to content

Commit

Permalink
feat: add Singleton class to REX
Browse files Browse the repository at this point in the history
  • Loading branch information
qudix committed May 28, 2024
1 parent b26fb7c commit f927a91
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions CommonLibF4/include/REX/REX.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,27 @@ namespace REX
std::underlying_type_t<
std::common_type_t<Args...>>>;
}

namespace REX
{
template <class T>
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;
};
}

0 comments on commit f927a91

Please sign in to comment.