#ifndef SINGLETON_H #define SINGLETON_H #include template class Singleton { public: static T* getInstance() noexcept(std::is_nothrow_constructible::value) { static T instance{token()}; return &instance; } virtual ~Singleton() =default; Singleton(const Singleton&)=delete; Singleton& operator =(const Singleton&)=delete; protected: struct token{}; // helper class Singleton() noexcept=default; }; #endif // SINGLETON_H