I am presenting an idea to create a unique instance of an object using templates.. This is very similar to Singleton design pattern..
The code may be look like this
static T * Instance()
static T* ptr = new T();
So it will give the same instance of the object always.. For example
int *pInst = UniqueFactory<int>::Instance();
*pInst = 11;
pInst = UniqueFactory<int>::Instance();
*pInst , points to the same unique instance.
Another example is ( UserData can be any struct or class etc. )
UserData *pData = UniqueFactory<UserData>::Instance();
Hopes you may like it..!!