From 0bd2e6d699388490638daa39cbc3ea0caed608eb Mon Sep 17 00:00:00 2001 From: humesikkins Date: Wed, 5 Mar 2003 23:38:43 +0000 Subject: [PATCH] added helper-macros for specializing std::less git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@112 7ec92016-0320-0410-acc4-a06ded1c099a --- MSVC/1200/SmartPtr.h | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/MSVC/1200/SmartPtr.h b/MSVC/1200/SmartPtr.h index 05f8550..b59224f 100644 --- a/MSVC/1200/SmartPtr.h +++ b/MSVC/1200/SmartPtr.h @@ -13,7 +13,8 @@ // without express or implied warranty. //////////////////////////////////////////////////////////////////////////////// -// Last update: Feb 24, 2003 +// Last update: Mar 06, 2003 + // ported RefCountedMT // To create a SmartPtr with RefCountedMT as ownership policy // use code like this: @@ -76,7 +77,6 @@ namespace Loki { - //////////////////////////////////////////////////////////////////////////////// // class template DefaultSPStorage // Implementation of the StoragePolicy used by SmartPtr @@ -128,7 +128,9 @@ namespace Loki // Destroys the data stored // (Destruction might be taken over by the OwnershipPolicy) void Destroy() - { delete pointee_; } + { + delete pointee_; + } // Default value to initialize the pointer static StoredType Default() @@ -1432,6 +1434,37 @@ namespace std { return less()(GetImpl(lhs), GetImpl(rhs)); } }; } +#else +// macros that help to specialize std::less for smarptrs. +#define SMARTPTR_SPECIALIZE_LESS_5(T, OP, CP, KP, SP) \ +namespace std \ +{ \ + struct less< Loki::SmartPtr > \ + : public binary_function, \ + Loki::SmartPtr, bool> \ + { \ + bool operator()(const Loki::SmartPtr& lhs, \ + const Loki::SmartPtr& rhs) const \ + { \ + typedef ApplyInnerType::type TempType; \ + const TempType& rlhs = lhs; \ + const TempType& rrhs = rhs; \ + return less()(GetImpl(rlhs), GetImpl(rrhs)); \ + } \ + }; \ +} + +#define SMARTPTR_SPECIALIZE_LESS_4(T, OP, CP, KP) \ + SMARTPTR_SPECIALIZE_LESS_5(T, OP, CP, KP, DefaultSPStorageWrapper) + +#define SMARTPTR_SPECIALIZE_LESS_3(T, OP, CP) \ + SMARTPTR_SPECIALIZE_LESS_5(T, OP, CP, AssertCheckWrapper, DefaultSPStorageWrapper) + +#define SMARTPTR_SPECIALIZE_LESS_2(T, OP) \ + SMARTPTR_SPECIALIZE_LESS_5(T, OP, DisallowConversion, AssertCheckWrapper, DefaultSPStorageWrapper) + +#define SMARTPTR_SPECIALIZE_LESS(T) \ + SMARTPTR_SPECIALIZE_LESS_5(T, RefCountedWrapper, DisallowConversion, AssertCheckWrapper, DefaultSPStorageWrapper) #endif //////////////////////////////////////////////////////////////////////////////// // Change log: @@ -1440,6 +1473,7 @@ namespace std // Oct 26, 2002: ported by Benjamin Kaufmann to MSVC 6.0 // Feb 24, 2003: ported RefCountedMT. In NoCopy replaced CT_ASSERT with // STATIC_CHECK. B.K. +// Mar 06, 2003: added helper-macros for specializing std::less for +// Smart-Pointers. //////////////////////////////////////////////////////////////////////////////// - #endif // SMARTPTR_INC_