mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-18 09:24:58 +00:00
27 lines
No EOL
344 B
C++
27 lines
No EOL
344 B
C++
#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;
|
|
}; |