[llvm-commits] [llvm] r149308 - /llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h
Ted Kremenek
kremenek at apple.com
Mon Jan 30 16:57:05 PST 2012
Author: kremenek
Date: Mon Jan 30 18:57:04 2012
New Revision: 149308
URL: http://llvm.org/viewvc/llvm-project?rev=149308&view=rev
Log:
Use traits for IntrusiveRefCntPtr to determine how to increment/decrement a reference count.
Modified:
llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h
Modified: llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h?rev=149308&r1=149307&r2=149308&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h (original)
+++ llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Mon Jan 30 18:57:04 2012
@@ -83,6 +83,12 @@
friend class IntrusiveRefCntPtr;
};
+
+ template <typename T> struct IntrusiveRefCntPtrInfo {
+ static void retain(T *obj) { obj->Retain(); }
+ static void release(T *obj) { obj->Release(); }
+ };
+
//===----------------------------------------------------------------------===//
/// IntrusiveRefCntPtr - A template class that implements a "smart pointer"
/// that assumes the wrapped object has a reference count associated
@@ -168,8 +174,8 @@
}
private:
- void retain() { if (Obj) Obj->Retain(); }
- void release() { if (Obj) Obj->Release(); }
+ void retain() { if (Obj) IntrusiveRefCntPtrInfo<T>::retain(Obj); }
+ void release() { if (Obj) IntrusiveRefCntPtrInfo<T>::release(Obj); }
void replace(T* S) {
this_type(S).swap(*this);
More information about the llvm-commits
mailing list