Original Post
I read the article on Singletons on gamedev (The One: A Singleton Discussion). I understand the necessity for them, but I was having trouble understanding the implementations. Meyer''s Singleton seems simple enough to me, but the nifty counter confused me. I was thinking that this could be enough (I like the idea of a template instead of implementing it as part of the class)
template <typename T> class Singleton
{
static T* SingletonClass;
public:
Singleton(){SingletonClass = new T;}
~Singleton(){delete SingletonClass;}
GetInstance(){return *SingletonClass}
GetPtrInstance(){return *SingletonClass}
};
This is very similar to the Ogre engine implementation, except by some act of god (confusing code that baffles me) they never allocate the pointer with new, and they never delete it.