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() {