Zero-Link error with template singletons
Zero-Link error with template singletons
- Subject: Zero-Link error with template singletons
- From: Bernard Gilbert <email@hidden>
- Date: Mon, 1 Dec 2003 21:17:38 -0500
If I run without the zero-link option everything is ok, with zero-link
my handle manager classes have problems. Here is my guess about what is
happening. Many of my managers are singletons that are coded using
template <typename T>
class Singleton
{
public:
static T& GetSingleton();
private:
Singleton& operator=( const Singleton& );
};
template< typename T >
T& Singleton<T>::GetSingleton()
{
static T theOne;
return theOne;
}
The manager class then inherent from the singleton like
class TimeMgr : public Singleton< TimeMgr >
using the class as the template argument to create a unique singleton
for the class. Some of the other managers are much more complex
templates, but the idea is the same. The problem seems to be if a use
zero-link I am getting more then one singleton for the same manager
class. Not good. The code is quite large, but I can look at creating
test cases if anyone is interested. For now, I just turned off
zero-link and kept working. Has anyone seen this problem, I didn't see
it in a quick glance through the archive.
Bernard Gilbert
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.