/* * singleton.h * * Created on: Sep 11, 2019 * Author: compi */ #ifndef SINGLETON_H_ #define SINGLETON_H_ #include namespace f4ll_cpp { template class Strangeton { public: static T &Instance() { return *m_instance; } template static T &Init(Args &&... args) { static T instance{ std::forward(args)... }; if(!m_instance) m_instance = &instance; return instance; } protected: Strangeton() = default; Strangeton(const Strangeton &) = delete; Strangeton &operator=(const Strangeton &) = delete; virtual ~Strangeton() = default; static T *m_instance; }; template T* Strangeton::m_instance = nullptr; } // f4ll_cpp #endif /* SINGLETON_H_ */