*
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#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__
|
||||
Reference in New Issue
Block a user