#pragma once #include #include template class singleton { public: static T* instance() { if (!m_instance) { m_instance = static_cast(std::malloc(sizeof(T))); new (m_instance) T; } return m_instance; } protected: singleton(); ~singleton(); private: static inline T* m_instance = nullptr; };