-//== llvm/ADT/IntrusiveRefCntPtr.h - Smart Refcounting Pointer ----*- C++ -*-==//
+//== llvm/ADT/IntrusiveRefCntPtr.h - Smart Refcounting Pointer ---*- C++ -*-==//
//
// The LLVM Compiler Infrastructure
//
/// inherit from RefCountedBaseVPTR can't be allocated on stack -
/// attempting to do this will produce a compile error.
//===----------------------------------------------------------------------===//
- template <class Derived>
class RefCountedBaseVPTR {
unsigned ref_cnt;
if (--ref_cnt == 0) delete this;
}
- friend class IntrusiveRefCntPtr<Derived>;
+ template <typename T>
+ friend class IntrusiveRefCntPtr;
};
//===----------------------------------------------------------------------===//
retain();
}
+ IntrusiveRefCntPtr& operator=(const IntrusiveRefCntPtr& S) {
+ replace(S.getPtr());
+ return *this;
+ }
+
template <class X>
IntrusiveRefCntPtr& operator=(const IntrusiveRefCntPtr<X>& S) {
replace(S.getPtr());
T* getPtr() const { return Obj; }
- typedef T * IntrusiveRefCntPtr::*unspecified_bool_type;
+ typedef T* (IntrusiveRefCntPtr::*unspecified_bool_type) () const;
operator unspecified_bool_type() const {
return Obj == 0 ? 0 : &IntrusiveRefCntPtr::getPtr;
}
other.Obj = Obj;
Obj = tmp;
}
+
+ void resetWithoutRelease() {
+ Obj = 0;
+ }
private:
void retain() { if (Obj) Obj->Retain(); }
void release() { if (Obj) Obj->Release(); }
void replace(T* S) {
- this_type(S).swap(this);
+ this_type(S).swap(*this);
}
};
} // end namespace llvm
-#endif // LLVM_ADT_INTRUSIVE_REF_CNT_PTR
\ No newline at end of file
+#endif // LLVM_ADT_INTRUSIVE_REF_CNT_PTR