ETL
0.04.19
|
Object Smart Pointer. More...
#include <ETL/smart_ptr>
Public Types | |
typedef T | value_type |
typedef T & | reference |
typedef const T & | const_reference |
typedef T * | pointer |
typedef const T * | const_pointer |
typedef int | count_type |
typedef int | size_type |
typedef D | destructor_type |
Public Member Functions | |
smart_ptr (value_type *obj, reference_counter refcount) | |
smart_ptr () | |
Default constructor - empty smart_ptr. | |
smart_ptr (value_type *x) | |
Constructor that constructs from a pointer to new object. | |
smart_ptr (const smart_ptr< value_type > &x) | |
Template copy constructor. | |
smart_ptr (const value_type &x) | |
~smart_ptr () | |
smart_ptr is released on deletion | |
template<class U > | |
const smart_ptr< value_type > & | operator= (const smart_ptr< U > &x) |
Template Assignment operator. | |
const smart_ptr< value_type > & | operator= (const smart_ptr< value_type > &x) |
Assignment operator. | |
void | reset () |
smart_ptr reset procedure | |
void | spawn () |
const count_type & | count () const |
Returns number of instances. | |
bool | unique () const |
Returns true if there is only one instance of the object. | |
smart_ptr< const value_type > | constant () |
Returns a constant handle to our object. | |
reference | operator* () const |
pointer | operator-> () const |
operator smart_ptr< const value_type > () const | |
pointer | get () const |
operator bool () const | |
More explicit bool cast. | |
bool | operator! () const |
template<class U > | |
operator smart_ptr< U > () | |
Overloaded cast operator – useful for implicit casts. |
Static Public Member Functions | |
template<class U > | |
static smart_ptr< T > | cast_static (const smart_ptr< U > &x) |
static_cast<> wrapper | |
template<class U > | |
static smart_ptr< T > | cast_dynamic (const smart_ptr< U > &x) |
dynamic_cast<> wrapper | |
template<class U > | |
static smart_ptr< T > | cast_const (const smart_ptr< U > &x) |
const_cast<> wrapper |
Private Attributes | |
value_type * | obj |
reference_counter | refcount |
Object Smart Pointer.
Definition at line 62 of file _smart_ptr.h.
typedef T smart_ptr< T, D >::value_type |
Definition at line 66 of file _smart_ptr.h.
Definition at line 67 of file _smart_ptr.h.
typedef const T& smart_ptr< T, D >::const_reference |
Definition at line 68 of file _smart_ptr.h.
Definition at line 69 of file _smart_ptr.h.
typedef const T* smart_ptr< T, D >::const_pointer |
Definition at line 70 of file _smart_ptr.h.
typedef int smart_ptr< T, D >::count_type |
Definition at line 71 of file _smart_ptr.h.
Definition at line 72 of file _smart_ptr.h.
typedef D smart_ptr< T, D >::destructor_type |
Definition at line 73 of file _smart_ptr.h.
|
inline |
Definition at line 83 of file _smart_ptr.h.
Default constructor - empty smart_ptr.
Definition at line 86 of file _smart_ptr.h.
Referenced by smart_ptr< T, D >::spawn().
|
inlineexplicit |
Constructor that constructs from a pointer to new object.
A new smart_ptr is created with a pointer to a newly allocated object. We need to be explicit with this so we don't accidently have two smart_ptrs for one object – that would be bad.
Definition at line 94 of file _smart_ptr.h.
|
inline |
Template copy constructor.
This template constructor allows us to cast smart_ptrs much like we would pointers. Default copy constructor
The template above is not good enough for all compilers. We need to explicitly define the copy constructor for this class to work on those compilers.
Definition at line 110 of file _smart_ptr.h.
|
inlineexplicit |
Definition at line 112 of file _smart_ptr.h.
smart_ptr is released on deletion
Definition at line 115 of file _smart_ptr.h.
References smart_ptr< T, D >::obj, smart_ptr< T, D >::refcount, and reference_counter::unique().
|
inline |
Template Assignment operator.
Definition at line 119 of file _smart_ptr.h.
References smart_ptr< T, D >::get(), smart_ptr< T, D >::obj, smart_ptr< T, D >::refcount, and smart_ptr< T, D >::reset().
Referenced by smart_ptr< T, D >::spawn().
|
inline |
Assignment operator.
Definition at line 137 of file _smart_ptr.h.
References smart_ptr< T, D >::get(), smart_ptr< T, D >::obj, smart_ptr< T, D >::refcount, and smart_ptr< T, D >::reset().
|
inline |
smart_ptr reset procedure
Definition at line 156 of file _smart_ptr.h.
References reference_counter::detach(), smart_ptr< T, D >::obj, smart_ptr< T, D >::refcount, and reference_counter::unique().
Referenced by smart_ptr< T, D >::operator=().
|
inline |
Definition at line 166 of file _smart_ptr.h.
References smart_ptr< T, D >::operator=(), and smart_ptr< T, D >::smart_ptr().
|
inline |
Returns number of instances.
Definition at line 169 of file _smart_ptr.h.
References smart_ptr< T, D >::refcount.
|
inline |
Returns true if there is only one instance of the object.
Definition at line 172 of file _smart_ptr.h.
References smart_ptr< T, D >::refcount, and reference_counter::unique().
|
inline |
Returns a constant handle to our object.
Definition at line 175 of file _smart_ptr.h.
|
inline |
Definition at line 177 of file _smart_ptr.h.
References smart_ptr< T, D >::obj.
|
inline |
Definition at line 179 of file _smart_ptr.h.
References smart_ptr< T, D >::obj.
|
inline |
Definition at line 182 of file _smart_ptr.h.
References smart_ptr< T, D >::obj.
|
inlinestatic |
static_cast<> wrapper
Definition at line 187 of file _smart_ptr.h.
References smart_ptr< T, D >::get(), NULL, and smart_ptr< T, D >::refcount.
|
inlinestatic |
dynamic_cast<> wrapper
Definition at line 192 of file _smart_ptr.h.
References smart_ptr< T, D >::get(), and smart_ptr< T, D >::refcount.
|
inlinestatic |
const_cast<> wrapper
Definition at line 197 of file _smart_ptr.h.
References smart_ptr< T, D >::get(), and smart_ptr< T, D >::refcount.
Definition at line 200 of file _smart_ptr.h.
References smart_ptr< T, D >::obj.
Referenced by smart_ptr< T, D >::cast_const(), smart_ptr< T, D >::cast_dynamic(), smart_ptr< T, D >::cast_static(), operator!=(), smart_ptr< T, D >::operator=(), and operator==().
|
inline |
More explicit bool cast.
Definition at line 203 of file _smart_ptr.h.
References smart_ptr< T, D >::obj.
|
inline |
Definition at line 205 of file _smart_ptr.h.
References smart_ptr< T, D >::obj.
|
inline |
Overloaded cast operator – useful for implicit casts.
Definition at line 209 of file _smart_ptr.h.
|
private |
Definition at line 78 of file _smart_ptr.h.
Referenced by smart_ptr< T, D >::get(), smart_ptr< T, D >::operator bool(), smart_ptr< T, D >::operator smart_ptr< const value_type >(), smart_ptr< T, D >::operator!(), smart_ptr< T, D >::operator*(), smart_ptr< T, D >::operator->(), smart_ptr< T, D >::operator=(), smart_ptr< T, D >::reset(), and smart_ptr< T, D >::~smart_ptr().
|
private |
Definition at line 79 of file _smart_ptr.h.
Referenced by smart_ptr< T, D >::cast_const(), smart_ptr< T, D >::cast_dynamic(), smart_ptr< T, D >::cast_static(), smart_ptr< T, D >::count(), smart_ptr< T, D >::operator=(), smart_ptr< T, D >::reset(), smart_ptr< T, D >::unique(), and smart_ptr< T, D >::~smart_ptr().