12 #ifndef ROC_CORE_SHARED_PTR_H_
13 #define ROC_CORE_SHARED_PTR_H_
31 template <
class T,
template <
class TT>
class OwnershipPolicy = RefCountedOwnership>
100 roc_panic(
"shared ptr: attempt to dereference null pointer");
108 roc_panic(
"shared ptr: attempt to dereference null pointer");
114 operator const struct unspecified_bool *()
const {
115 return (
const unspecified_bool*)ptr_;
121 OwnershipPolicy<T>::acquire(*ptr_);
127 OwnershipPolicy<T>::release(*ptr_);
135 template <
class T1,
class T2>
137 return a.
get() == b.
get();
141 template <
class T1,
class T2>
143 return a.
get() != b.
get();
Shared ownership intrusive pointer.
SharedPtr(const SharedPtr< TT, OwnershipPolicy > &other)
Create shared pointer from shared pointer of another type.
~SharedPtr()
Destroy shared pointer.
T * get() const
Get underlying pointer.
SharedPtr & operator=(const SharedPtr &other)
Reset shared pointer and attach it to another object.
SharedPtr(const SharedPtr &other)
Create shared pointer from shared pointer of the same type.
void reset(T *ptr=NULL)
Reset shared pointer and attach it to another object.
void reset(const SharedPtr &other)
Reset shared pointer and attach it to another object.
T & operator*() const
Get underlying reference.
SharedPtr()
Create empty shared pointer.
SharedPtr(T *ptr)
Create shared pointer from raw pointer.
T * operator->() const
Get underlying pointer.
bool operator!=(const SharedPtr< T1 > &a, const SharedPtr< T2 > &b)
Equality check.
bool operator==(const SharedPtr< T1 > &a, const SharedPtr< T2 > &b)
Equality check.
#define roc_panic(...)
Print error message and terminate program gracefully.
Commonly used types and functions.