quote:Original post by fizban75
How about if you try:
..source...
I already tried this approach, but got exactly the same behaviour, strangely enough. Thanks anyway though.
eloso: Thanks for that, but it doesn't work, presumably because the function is in a template.
quote:Original post by Yanroy
...but it seems to me that instead of jumping through hoops to turn off your inlining, you could just define the body of the inst() function in the .cpp file
Yes, that works, but I just like to be able to declare that a class is a Singleton and then use it as such. It seems neater that way.
However, since that isn't possible with VC6.0 I'm forced to abandon the Singleton template altogether. Here's my hacked solution:
//in singleton.h#define SINGLETON_INSTFUNC(type) static type &inst(){static type inst; return inst;}//Foo Singleton declarationclass Foo{ Foo()public: SINGLETON_INSTFUNC(Foo)}
The end result actually needs less typing than the initial solution, although it isn't exactly elegant.
[edited by - benjamin bunny on August 7, 2003 10:59:41 AM]