|
#pragma once
#include <memory>
using namespace std;
template<class _Tr,class _Ac>
class singleton
...{
public:
singleton()
...{
if(m_ptr.get() == NULL)
...{
m_ptr.reset(new _Tr());
}
}
singleton(const _Ac& args)
...{
if(m_ptr.get() == NULL)
...{
m_ptr.reset(new _Tr(args));
}
}
_Tr* operator->()const
...{
return m_ptr.get();
}
_Tr& operator*()const
...{
return *m_ptr;
}
public:
~singleton(void)
...{
}
private:
static auto_ptr<_Tr> m_ptr;
};
template<class _Tr,class _Ac>
auto_ptr<_Tr> singleton<_Tr,_Ac>::m_ptr;
|
|