mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-17 17:05:02 +00:00
24 lines
No EOL
398 B
C++
24 lines
No EOL
398 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;
|
|
}; |