12#ifndef ROC_CORE_SCOPED_PTR_H_
13#define ROC_CORE_SCOPED_PTR_H_
31template <
class T,
class AllocationPolicy = StandardAllocation>
58 void reset(T* new_ptr,
const AllocationPolicy& new_policy) {
59 if (new_ptr != ptr_) {
70 roc_panic(
"uniqueptr: attempting to release a null pointer");
89 roc_panic(
"unique ptr: attempting to dereference a null pointer");
95 operator const struct unspecified_bool *()
const {
96 return (unspecified_bool*)ptr_;
102 policy_.destroy(*ptr_);
107 AllocationPolicy policy_;
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.
Memory allocator interface.
#define roc_panic(...)
Print error message and terminate program gracefully.
Commonly used types and functions.