From 0201647cdcfb6ee57262fba8dfdaa2ae9140b693 Mon Sep 17 00:00:00 2001 From: rich_sposato Date: Wed, 5 Apr 2006 22:41:43 +0000 Subject: [PATCH] Fixed bug 1459838 using fix made by Thomas Albrecht. (Thanks!) Also added a constructor for NoCheck policy. git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@622 7ec92016-0320-0410-acc4-a06ded1c099a --- include/loki/SmartPtr.h | 62 +++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/include/loki/SmartPtr.h b/include/loki/SmartPtr.h index ba8eae9..376ef26 100644 --- a/include/loki/SmartPtr.h +++ b/include/loki/SmartPtr.h @@ -260,7 +260,15 @@ namespace Loki assert(pCount_!=0); *pCount_ = 1; } - + + RefCounted( const P & ) + : pCount_(static_cast( + SmallObject<>::operator new(sizeof(uintptr_t)))) + { + assert(pCount_!=0); + *pCount_ = 1; + } + RefCounted(const RefCounted& rhs) : pCount_(rhs.pCount_) {} @@ -329,6 +337,16 @@ namespace Loki ThreadingModel::AtomicAssign(*pCount_, 1); } + RefCountedMT( const P & ) + { + pCount_ = static_cast( + SmallObject::operator new( + sizeof(*pCount_))); + assert(pCount_); + //*pCount_ = 1; + ThreadingModel::AtomicAssign(*pCount_, 1); + } + RefCountedMT(const RefCountedMT& rhs) : pCount_(rhs.pCount_) {} @@ -382,7 +400,13 @@ namespace Loki public: COMRefCounted() {} - + + COMRefCounted(const P& val) + { + if(val!=0) + val->AddRef(); + } + template COMRefCounted(const COMRefCounted&) {} @@ -421,7 +445,10 @@ namespace Loki { DeepCopy() {} - + + DeepCopy( const P & ) + {} + template DeepCopy(const DeepCopy&) {} @@ -481,7 +508,10 @@ namespace Loki public: RefLinked() {} - + + RefLinked( const P & ) + {} + template RefLinked(const RefLinked& rhs) : Private::RefLinkedBase(rhs) @@ -514,7 +544,10 @@ namespace Loki public: DestructiveCopy() {} - + + DestructiveCopy( const P & ) + {} + template DestructiveCopy(const DestructiveCopy&) {} @@ -550,7 +583,10 @@ namespace Loki public: NoCopy() {} - + + NoCopy( const P & ) + {} + template NoCopy(const NoCopy&) {} @@ -619,6 +655,8 @@ namespace Loki /// Well, it's clear what it does :o) //////////////////////////////////////////////////////////////////////////////// + template < class P > struct AssertCheck; + template struct NoCheck { @@ -629,6 +667,10 @@ namespace Loki NoCheck(const NoCheck&) {} + template + NoCheck(const AssertCheck&) + {} + static void OnDefault(const P&) {} @@ -963,10 +1005,10 @@ namespace Loki { KP::OnDefault(GetImpl(*this)); } explicit - SmartPtr(ExplicitArg p) : SP(p) + SmartPtr(ExplicitArg p) : SP(p), OP(p) { KP::OnInit(GetImpl(*this)); } - SmartPtr(ImplicitArg p) : SP(p) + SmartPtr(ImplicitArg p) : SP(p), OP(p) { KP::OnInit(GetImpl(*this)); } SmartPtr(CopyArg& rhs) @@ -1520,6 +1562,10 @@ namespace std #endif // SMARTPTR_INC_ // $Log$ +// Revision 1.29 2006/04/05 22:41:43 rich_sposato +// Fixed bug 1459838 using fix made by Thomas Albrecht. (Thanks!) +// Also added a constructor for NoCheck policy. +// // Revision 1.28 2006/03/27 18:38:30 rich_sposato // Added check for NULL pointer in HeapStorage policy. //