#pragma once /** Пример: * * class Derived : public Singleton * { * friend class Singleton; * ... * protected: * Derived() {}; * }; * * Или так: * * class Some * { * ... * }; * * class SomeSingleton : public Some, public Singleton {} */ template class Singleton { public: static Subject & instance() { /// Нормально при включенных thread safe statics в gcc (по-умолчанию). static Subject instance; return instance; } protected: Singleton(){}; private: Singleton(const Singleton&); Singleton& operator=(const Singleton&); };