From 13d56ada49d3150e2c43229a00c64f20b61a4d2d Mon Sep 17 00:00:00 2001 From: syntheticpp Date: Wed, 5 Oct 2005 09:08:42 +0000 Subject: [PATCH] the greater the value of longevity the greater the lifetime. git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@280 7ec92016-0320-0410-acc4-a06ded1c099a --- include/loki/Singleton.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/loki/Singleton.h b/include/loki/Singleton.h index 1402cee..5d874bd 100644 --- a/include/loki/Singleton.h +++ b/include/loki/Singleton.h @@ -52,7 +52,7 @@ namespace Loki static bool Compare(const LifetimeTracker* lhs, const LifetimeTracker* rhs) { - return lhs->longevity_ < rhs->longevity_; + return lhs->longevity_ > rhs->longevity_; } private: @@ -71,6 +71,7 @@ namespace Loki template struct Deleter { + typedef void (*Type)(T*); static void Delete(T* pObj) { delete pObj; } }; @@ -105,7 +106,7 @@ namespace Loki template void SetLongevity(T* pDynObject, unsigned int longevity, - Destroyer d = Private::Deleter::Delete) + Destroyer d) { using namespace Private; @@ -137,6 +138,13 @@ namespace Loki std::atexit(Private::AtExitFn); } + template + void SetLongevity(T* pDynObject, unsigned int longevity, + typename Private::Deleter::Type d = Private::Deleter::Delete) + { + SetLongevity::Type>(pDynObject, longevity, d); + } + //////////////////////////////////////////////////////////////////////////////// // class template CreateUsingNew // Implementation of the CreationPolicy used by SingletonHolder