From 2dd3452a84199782b59a74a0e752c79cf4aa5850 Mon Sep 17 00:00:00 2001 From: syntheticpp Date: Wed, 15 Mar 2006 08:47:19 +0000 Subject: [PATCH] gcc: specialization only in the correct namespace, thx to Sam Miller git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@608 7ec92016-0320-0410-acc4-a06ded1c099a --- include/loki/Singleton.h | 31 +++++++++++++++++++----------- test/SingletonDll/singletondll.cpp | 14 +++++++++----- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/include/loki/Singleton.h b/include/loki/Singleton.h index eaa634e..7e2ed51 100644 --- a/include/loki/Singleton.h +++ b/include/loki/Singleton.h @@ -855,19 +855,25 @@ namespace Loki static T& Instance(); }; - /// \def LOKI_SINGLETON_INSTANCE_DEFINITION(SHOLDER) - /// Convenience macro for the definition of the static Instance member function - /// Put this macro called with a SingletonHolder typedef into your cpp file. - -#define LOKI_SINGLETON_INSTANCE_DEFINITION(SHOLDER) \ - template<> \ - SHOLDER::ObjectType& ::Loki::Singleton::Instance() \ - { \ - return SHOLDER::Instance(); \ - } - } // namespace Loki + +/// \def LOKI_SINGLETON_INSTANCE_DEFINITION(SHOLDER) +/// Convenience macro for the definition of the static Instance member function +/// Put this macro called with a SingletonHolder typedef into your cpp file. + +#define LOKI_SINGLETON_INSTANCE_DEFINITION(SHOLDER) \ +namespace Loki \ +{ \ + template<> \ + SHOLDER::ObjectType& Singleton::Instance() \ + { \ + return SHOLDER::Instance(); \ + } \ +} + + + //////////////////////////////////////////////////////////////////////////////// // Change log: // May 21, 2001: Correct the volatile qualifier - credit due to Darin Adler @@ -883,6 +889,9 @@ namespace Loki #endif // SINGLETON_INC_ // $Log$ +// Revision 1.29 2006/03/15 08:47:18 syntheticpp +// gcc: specialization only in the correct namespace, thx to Sam Miller +// // Revision 1.28 2006/03/03 11:58:24 syntheticpp // also compile with gcc // diff --git a/test/SingletonDll/singletondll.cpp b/test/SingletonDll/singletondll.cpp index 1098f14..ebfbeb4 100755 --- a/test/SingletonDll/singletondll.cpp +++ b/test/SingletonDll/singletondll.cpp @@ -21,13 +21,17 @@ typedef Loki::SingletonHolder FooSingleton; LOKI_SINGLETON_INSTANCE_DEFINITION(FooSingleton) /* -// code generated by the macro: -Foo& Loki::Singleton::Instance() -{ - return FooSingleton::Instance(); -}; +namespace Loki +{ + template<> + FooSingleton::ObjectType& Singleton::Instance() + { + return FooSingleton::Instance(); + } +} */ + template<> Foo& Singleton::Instance() {