1 #ifndef UTILS_SMART_POINTER_H 2 #define UTILS_SMART_POINTER_H 5 #include <KrisLibrary/errors.h> 19 inline bool isNull()
const {
return (ptr == NULL); }
20 inline operator const T* ()
const {
return ptr; }
21 inline operator T* () {
return ptr; }
22 inline T* operator ->() {
return ptr; }
23 inline const T* operator ->()
const {
return ptr; }
24 inline T& operator *() {
return *ptr; }
25 inline const T& operator *()
const {
return *ptr; }
26 inline bool isNonUnique()
const;
27 inline int getRefCount()
const;
36 : ptr(_ptr), refCount(NULL)
40 Assert(refCount != NULL);
47 : ptr(other.ptr), refCount(other.refCount)
56 if (refCount != NULL && --(*refCount) == 0) {
66 return refCount == NULL ?
false : *refCount != 1;
71 return refCount == NULL ? 0 : *refCount;
77 if (refCount != NULL && --(*refCount) == 0) {
82 refCount = rhs.refCount;
A smart pointer class. Performs automatic reference counting.
Definition: SmartPointer.h:12