diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-01-31 00:57:04 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-01-31 00:57:04 +0000 |
commit | 0004d86704f5c116e43bb6f867d3eba7423640e5 (patch) | |
tree | d08eae6a4ee5e2aef3b5e625e552d64371f597b4 /include | |
parent | 27b5658affba5b12b396048d2cc598c70719bfc5 (diff) | |
download | external_llvm-0004d86704f5c116e43bb6f867d3eba7423640e5.zip external_llvm-0004d86704f5c116e43bb6f867d3eba7423640e5.tar.gz external_llvm-0004d86704f5c116e43bb6f867d3eba7423640e5.tar.bz2 |
Use traits for IntrusiveRefCntPtr to determine how to increment/decrement a reference count.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/IntrusiveRefCntPtr.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/llvm/ADT/IntrusiveRefCntPtr.h b/include/llvm/ADT/IntrusiveRefCntPtr.h index 1d7e463..b5b7a51 100644 --- a/include/llvm/ADT/IntrusiveRefCntPtr.h +++ b/include/llvm/ADT/IntrusiveRefCntPtr.h @@ -83,6 +83,12 @@ namespace llvm { 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 @@ namespace llvm { } 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); |