12 #ifndef ROC_CORE_SHARED_PTR_H_
13 #define ROC_CORE_SHARED_PTR_H_
27 template <
class T,
template <
class TT>
class Ownership = RefCntOwnership>
96 roc_panic(
"shared ptr: attempting to dereference null shared pointer");
102 operator const struct unspecified_bool*()
const {
103 return (
const unspecified_bool*)ptr_;
109 Ownership<T>::acquire(*ptr_);
115 Ownership<T>::release(*ptr_);
123 template <
class T1,
class T2>
125 return (a.
get() == b.
get());
Shared ownership intrusive pointer.
T & operator*() const
Get underlying reference.
SharedPtr(T *ptr)
Create shared pointer from raw pointer.
~SharedPtr()
Destroy shared pointer.
void reset(T *ptr=NULL)
Reset shared pointer and attach it to another object.
T * get() const
Get underlying pointer.
SharedPtr()
Create empty shared pointer.
T * operator->() const
Get underlying pointer.
SharedPtr & operator=(const SharedPtr &other)
Reset shared pointer and attach it to another object.
SharedPtr(const SharedPtr< TT, Ownership > &other)
Create shared pointer from shared pointer of another type.
SharedPtr(const SharedPtr &other)
Create shared pointer from shared pointer of the same type.
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.