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
This commit is contained in:
syntheticpp 2006-03-15 08:47:19 +00:00
parent 60ef3a12e2
commit 2dd3452a84
2 changed files with 29 additions and 16 deletions

View file

@ -855,19 +855,25 @@ namespace Loki
static T& Instance(); 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<SHOLDER::ObjectType>::Instance() \
{ \
return SHOLDER::Instance(); \
}
} // namespace Loki } // 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<SHOLDER::ObjectType>::Instance() \
{ \
return SHOLDER::Instance(); \
} \
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Change log: // Change log:
// May 21, 2001: Correct the volatile qualifier - credit due to Darin Adler // May 21, 2001: Correct the volatile qualifier - credit due to Darin Adler
@ -883,6 +889,9 @@ namespace Loki
#endif // SINGLETON_INC_ #endif // SINGLETON_INC_
// $Log$ // $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 // Revision 1.28 2006/03/03 11:58:24 syntheticpp
// also compile with gcc // also compile with gcc
// //

View file

@ -21,13 +21,17 @@ typedef Loki::SingletonHolder<Foo> FooSingleton;
LOKI_SINGLETON_INSTANCE_DEFINITION(FooSingleton) LOKI_SINGLETON_INSTANCE_DEFINITION(FooSingleton)
/* /*
// code generated by the macro: namespace Loki
Foo& Loki::Singleton<Foo>::Instance() {
{ template<>
return FooSingleton::Instance(); FooSingleton::ObjectType& Singleton<FooSingleton::ObjectType>::Instance()
}; {
return FooSingleton::Instance();
}
}
*/ */
template<> template<>
Foo& Singleton<Foo>::Instance() Foo& Singleton<Foo>::Instance()
{ {