diff --git a/include/mapnik/utils.hpp b/include/mapnik/utils.hpp index a9f013f5b..0dbe28b6d 100644 --- a/include/mapnik/utils.hpp +++ b/include/mapnik/utils.hpp @@ -84,54 +84,36 @@ public: static MaxAlign staticMemory; return new(&staticMemory) T; } -#ifdef __SUNPRO_CC -// Sun C++ Compiler doesn't handle `volatile` keyword same as GCC. - static void destroy(T* obj) -#else - static void destroy(volatile T* obj) -#endif + static void destroy(volatile T* obj) { obj->~T(); } }; -#ifdef __GNUC__ + template class CreatePolicy=CreateStatic> class MAPNIK_DECL singleton { -#else - template class CreatePolicy=CreateStatic> class singleton + friend class CreatePolicy; + static T* pInstance_; + static bool destroyed_; + singleton(const singleton &rhs); + singleton& operator=(const singleton&); + + static void onDeadReference() { -#endif + throw std::runtime_error("dead reference!"); + } -#ifdef __SUNPRO_CC -/* Sun's C++ compiler will issue the following errors if CreatePolicy is used: - Error: A class template name was expected instead of mapnik::CreatePolicy - Error: A "friend" declaration must specify a class or function. -*/ - friend class CreatePolicy; -#else - friend class CreatePolicy; -#endif - static T* pInstance_; - static bool destroyed_; - singleton(const singleton &rhs); - singleton& operator=(const singleton&); + static void DestroySingleton() + { + CreatePolicy::destroy(pInstance_); + pInstance_ = 0; + destroyed_ = true; + } - static void onDeadReference() - { - throw std::runtime_error("dead reference!"); - } +protected: - static void DestroySingleton() - { - CreatePolicy::destroy(pInstance_); - pInstance_ = 0; - destroyed_ = true; - } - - protected: #ifdef MAPNIK_THREADSAFE static mutex mutex_; #endif @@ -162,7 +144,8 @@ template class CreatePolicy> mutex singleton::mutex_;