shadPS4/src/common/singleton.h
2023-11-05 16:56:28 +02:00

26 lines
383 B
C++

#pragma once
#include <memory>
namespace Common {
template <class T>
class Singleton {
public:
static T* Instance() {
if (!m_instance) {
m_instance = std::make_unique<T>();
}
return m_instance.get();
}
protected:
Singleton();
~Singleton();
private:
static inline std::unique_ptr<T> m_instance{};
};
} // namespace Common