16 lines
315 B
C++
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;
|
|
}
|
|
}; |