mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-19 09:54:54 +00:00
initial work on linker
This commit is contained in:
parent
76987fb932
commit
a09e2eb65a
4 changed files with 68 additions and 1 deletions
27
src/Util/Singleton.h
Normal file
27
src/Util/Singleton.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#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;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue