Files
LifeProject/LifeCore/Singleton.h
T
2025-05-13 02:46:21 +03:00

27 lines
443 B
C++

#ifndef ___SINGLETON_H__
#define ___SINGLETON_H__
#include <memory>
template <typename T>
class Singleton
{
private:
static std::auto_ptr<T> instance;
Singleton(const Singleton& rval){}
public:
Singleton(){}
virtual ~Singleton(){}
static T *me()
{
if (!instance.get())
instance.reset(new T());
return instance.get();
}
};
template <class T>
std::auto_ptr<T> Singleton<T>::instance;
#endif // ___SINGLETON_H__