refactoring singleton class

This commit is contained in:
georgemoralis
2023-10-15 10:03:26 +03:00
parent 0f80805d69
commit 58721d84a0
12 changed files with 44 additions and 71 deletions

View File

@@ -1,27 +0,0 @@
#pragma once
#include <cstdlib>
#include <new>
template <class T>
class Singleton
{
public:
static T* Instance()
{
if (!m_instance)
{
m_instance = static_cast<T*>(std::malloc(sizeof(T)));
new (m_instance) T;
}
return m_instance;
}
protected:
Singleton();
~Singleton();
private:
static inline T* m_instance = nullptr;
};