9 #if !defined(_smart_ptr_h_) 23 typedef const T *const_ptr_type;
25 typedef const T &const_ref_type;
43 ptr_type
get() {
return _p; }
45 const_ptr_type
get()
const {
return _p; }
79 operator ptr_type() {
return _p; }
81 operator const_ptr_type()
const {
return _p; }
83 operator ref_type() {
return *
_p; }
85 operator const_ref_type()
const {
return *
_p; }
87 operator bool()
const {
return _p != 0; }
91 set(
const_cast<ptr_type
>(p));
120 template <
typename T>
126 typedef const T *const_ptr_type;
128 typedef const T &const_ref_type;
146 ptr_type
get() {
return _p; }
148 const_ptr_type
get()
const {
return _p; }
182 operator ptr_type() {
return _p; }
184 operator const_ptr_type()
const {
return _p; }
186 operator ref_type() {
return *
_p; }
188 operator const_ref_type()
const {
return *
_p; }
190 operator bool()
const {
return _p != 0; }
194 set(
const_cast<ptr_type
>(p));
218 #endif // _smart_ptr_h_ void clear()
Dissociates a previously set pointer value, deleting it at the same time.
Definition: apps/elftosb/common/smart_ptr.h:62
virtual void safe_delete()
Definition: apps/elftosb/common/smart_ptr.h:66
smart_array_ptr()
Default constuctor. Initialises with no pointer set.
Definition: apps/elftosb/common/smart_ptr.h:131
ptr_type _p
The wrapped pointer.
Definition: apps/elftosb/common/smart_ptr.h:215
virtual ~smart_array_ptr()
Definition: apps/elftosb/common/smart_ptr.h:144
virtual void safe_delete()
Definition: apps/elftosb/common/smart_ptr.h:169
smart_ptr()
Default constuctor. Initialises with no pointer set.
Definition: apps/elftosb/common/smart_ptr.h:28
smart_array_ptr< T > & operator=(const_ptr_type p)
To allow setting the pointer directly. Equivalent to a call to set().
Definition: apps/elftosb/common/smart_ptr.h:192
smart_ptr(ptr_type p)
This constructor takes a pointer to the object to be deleted.
Definition: apps/elftosb/common/smart_ptr.h:34
Simple, standard smart pointer class.
Definition: apps/elftosb/common/smart_ptr.h:18
void reset()
Dissociates any previously set pointer value without deleting it.
Definition: apps/elftosb/common/smart_ptr.h:60
void reset()
Dissociates any previously set pointer value without deleting it.
Definition: apps/elftosb/common/smart_ptr.h:163
void clear()
Dissociates a previously set pointer value, deleting it at the same time.
Definition: apps/elftosb/common/smart_ptr.h:165
ptr_type _p
The wrapped pointer.
Definition: apps/elftosb/common/smart_ptr.h:108
const_ptr_type operator->() const
Another operator to allow you to treat the object just like a pointer.
Definition: apps/elftosb/common/smart_ptr.h:201
smart_array_ptr(ptr_type p)
This constructor takes a pointer to the object to be deleted.
Definition: apps/elftosb/common/smart_ptr.h:137
const_ptr_type operator->() const
Another operator to allow you to treat the object just like a pointer.
Definition: apps/elftosb/common/smart_ptr.h:98
Simple, standard smart pointer class that uses the array delete operator.
Definition: apps/elftosb/common/smart_ptr.h:121
ptr_type operator->()
Another operator to allow you to treat the object just like a pointer.
Definition: apps/elftosb/common/smart_ptr.h:96
smart_ptr< T > & operator=(const_ptr_type p)
To allow setting the pointer directly. Equivalent to a call to set().
Definition: apps/elftosb/common/smart_ptr.h:89
ptr_type operator->()
Another operator to allow you to treat the object just like a pointer.
Definition: apps/elftosb/common/smart_ptr.h:199
ref_type operator[](unsigned index)
Indexing operator.
Definition: apps/elftosb/common/smart_ptr.h:203
const_ref_type operator[](unsigned index) const
Indexing operator.
Definition: apps/elftosb/common/smart_ptr.h:205
virtual ~smart_ptr()
Definition: apps/elftosb/common/smart_ptr.h:41