zengine/engine/modules/engine/core/3rdparty/singleton.h
2024-09-21 17:19:22 +08:00

16 lines
325 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 constexpr T* Ptr(void) {
return ms_Singleton;
}
};