summaryrefslogtreecommitdiff
path: root/indra/llcommon/llmemory.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llmemory.h')
-rw-r--r--indra/llcommon/llmemory.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index b0a47b6820..cc57e658fb 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -419,6 +419,31 @@ protected:
// Foo* instance = FooSingleton::getInstance();
//
// As currently written, it is not thread-safe.
+#if LL_WINDOWS && _MSC_VER < 1400 // this is Visual C++ 2003 or earlier
+// workaround for VC7 compiler bug
+// adapted from http://www.codeproject.com/KB/tips/VC2003MeyersSingletonBug.aspx
+// our version doesn't introduce a nested struct so that you can still declare LLSingleton<MyClass>
+// a friend and hide your constructor
+
+template <typename T>
+class LLSingleton
+{
+public:
+ static T* getInstance()
+ {
+ LLSingleton<T> singleton;
+ return singleton.get();
+ }
+private:
+ T* get()
+ {
+ static T instance;
+ return &instance;
+ }
+
+};
+#else
+
template <typename T>
class LLSingleton
{
@@ -430,6 +455,8 @@ public:
}
};
+#endif
+
//----------------------------------------------------------------------------
// Return the resident set size of the current process, in bytes.