zengine/engine/modules/engine/core/3rdparty/singleton.h
2024-10-21 16:31:02 +08:00

16 lines
315 B
C++

#pragma once
template <typename T>
class Singleton{
protected:
inline static T* ms_Singleton = nullptr;
public:
explicit Singleton() {
ms_Singleton = static_cast<T*>(this);
}
~Singleton() {
ms_Singleton = nullptr;
}
static T* Ptr(void) {
return ms_Singleton;
}
};