Skip to content

Commit

Permalink
Use traits for IntrusiveRefCntPtr to determine how to increment/decre…
Browse files Browse the repository at this point in the history
…ment a reference count.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149308 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
tkremenek committed Jan 31, 2012
1 parent 27b5658 commit 0004d86
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/llvm/ADT/IntrusiveRefCntPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0004d86

Please sign in to comment.