12#ifndef ROC_CORE_SCOPED_PTR_H_
13#define ROC_CORE_SCOPED_PTR_H_
32template <
class T,
class AllocationPolicy = ArenaAllocation>
43 policy_.
reset(
new (policy_) AllocationPolicy(
policy));
54 policy_->destroy(*ptr_);
74 roc_panic(
"scoped ptr: attempting to release a null pointer");
96 roc_panic(
"scoped ptr: attempting to dereference a null pointer");
Base class for non-copyable objects.
void reset(T *new_ptr, const AllocationPolicy &new_policy)
Reset pointer to a new value.
T * operator->() const
Get underlying pointer.
T * get() const
Get underlying pointer.
T * release()
Get underlying pointer and pass ownership to the caller.
void reset()
Reset pointer to null.
T & operator*() const
Get underlying reference.
ScopedPtr(T *ptr, const AllocationPolicy &policy)
Initialize from a raw pointer.
~ScopedPtr()
Destroy object.
ScopedPtr()
Initialize null pointer.
Shared ownership intrusive pointer.
void reset(const SharedPtr &other)
Reset shared pointer and attach it to another object.
Optionally constructed object.
#define roc_panic(...)
Print error message and terminate program gracefully.
Commonly used types and functions.