Thanks Fruny. I guess that i have to live with that solution. As i see it, ther is no workaround, especially after what Neophyte mentioned.
And to Anonymous poster: I know it might look weird, but believe me it's fully legit. To easen you grief, i'm gonna explain what i'm trying to do:
I am building a singleton system, but a slight more advanced singleton than the usual type singleton
template <class T>class singleton{private: static T instance;public: T &operator() () {return(instance);};}
What i am aiming for is a singleton system that creates a singleton for a specific class AND a specific parameter!
My goal is to be able to use the system like this:
singleton<int> a;singleton<int> b; //same as asingleton<int,OneParameter<int,int,5> > c; //uniquesingleton<int,OneParameter<int,int,6> > d; //uniquesingleton<int,OneParameter<int,int,5> > e; //same as ccout << a() << endl; //No idea what it will print. (Probably a compiler error =)cout << b() << endl; //No idea, but the same as a. cout << c() << endl; //5cout << d() << endl; //6cout << e() << endl; //5c() = 99;cout << e() << endl; //Note that i call e, not c. But it will still print 99.
where OneParameter =
template <class T, class PT, PT parameter>class OneParameter{ public: static T *instanciate() { return(new T(parameter)); }};
Of course, there are also classes like NoParameter (which is defult if no creator class is defined) and TwoParameters, etc
...and The MAIN goal is (well was) to use it like
void createAsteroid(){ Entity *newentity; //The ONE and ONLY instance of the asteroid model! //It's there for availability during the entire execution, //and it's ONLY LOADED ONCE! singleton<MD2_Model, OneParameter<MD2_Model,char*,"data/asteroid.md2"> > asteroid; newentity = new Entity(); //Set some properties newentity.position.set(0,0,0); newentity.model = &asteroid(); //point to the asteroid model //..and this is the world handler sigleton. Only one, and //VERY easy to reach. singleton<WorldHandler> worldhandler; worldhandler().addUnit(newentity);};
--Electron"The truth can be changed simply by the way you accept it.""'General failure trying to read from file' - who is General Failure, and why is he reading my file??"