![]() |
Object-oriented Scientific Computing Library: Version 0.910
|
The internal shared pointer class used if no TR1 or Boost implementation is available. More...
#include <shared_ptr.h>
See also o2_shared_ptr .
This class was based on the Aegis shared_ptr
class from http:://aegis.sourceforge.net, but is implemented in O2scl using a template struct rather than a define constant.
Definition at line 60 of file shared_ptr.h.
Public Member Functions | |
o2_int_shared_ptr () | |
Create an empty shared_ptr. | |
template<class Y > | |
o2_int_shared_ptr (Y *rhs) | |
Create a shared pointer. | |
o2_int_shared_ptr (const o2_int_shared_ptr &rhs) | |
Copy constructor. | |
template<class Y > | |
o2_int_shared_ptr (const o2_int_shared_ptr< Y > &rhs) | |
Copy constructor for compatible pointer types. | |
bool | valid () const |
Test if the shared_ptr object is valid. | |
void | swap (o2_int_shared_ptr &rhs) |
Swap. | |
void | reset () |
Drop the reference and set the pointer to zero. | |
o2_int_shared_ptr & | operator= (const o2_int_shared_ptr &rhs) |
Assignment operator. | |
template<class Y > | |
o2_int_shared_ptr & | operator= (const o2_int_shared_ptr< Y > &rhs) |
Assignment operator for compatible pointer types. | |
T & | operator* () const |
Dereference operator. | |
T * | operator-> () const |
Pointing at operator. | |
T * | get () const |
Return a pointer to the object. | |
operator bool () const | |
Return true if the pointer is not zero. | |
bool | operator! () const |
Logical not operator. | |
bool | operator== (const o2_int_shared_ptr &rhs) const |
Test equality. | |
template<class U > | |
bool | operator== (const o2_int_shared_ptr< U > &rhs) const |
Test equality for compatible pointer types. | |
bool | operator!= (o2_int_shared_ptr &rhs) const |
Test inequality. | |
template<class U > | |
bool | operator!= (o2_int_shared_ptr< U > &rhs) const |
Test inequality for compatible pointer types. | |
bool | operator< (o2_int_shared_ptr &rhs) const |
Less than operator. | |
template<class U > | |
bool | operator< (o2_int_shared_ptr< U > &rhs) const |
Less than operator for compatible pointer types. | |
Private Attributes | |
long * | reference_count |
Reference count. | |
T * | subject |
Object being pointed to. | |
Friends | |
class | o2_int_shared_ptr |
o2_int_shared_ptr< T >::o2_int_shared_ptr | ( | Y * | rhs | ) | [inline, explicit] |
This constructor permits initialization from any compatable pointer where Y
must be a complete type.
Definition at line 105 of file shared_ptr.h.
bool o2_int_shared_ptr< T >::valid | ( | ) | const [inline] |
This method verifies that the internal state of the shared pointer object is valid.
Definition at line 163 of file shared_ptr.h.
void o2_int_shared_ptr< T >::swap | ( | o2_int_shared_ptr< T > & | rhs | ) | [inline] |
Swap the contents of two o2_int_shared_ptr<T> objects. This method is more efficient than manually swapping shared_ptr objects using a copy constructor or temporary.
Definition at line 174 of file shared_ptr.h.
bool o2_int_shared_ptr< T >::operator! | ( | ) | const [inline] |
Return true if and only if the pointer is zero.
Definition at line 282 of file shared_ptr.h.
long* o2_int_shared_ptr< T >::reference_count [private] |
Documentation from Aegis:
The reference_count instance variable is used to remember the location of the reference count. By having the reference count separate from the subject, we can cope with compatible pointers, not just exact pointers. This is not ideal because it allocates huge numbers of small objects. Some heap implementations go slowly when faced with many small allocations. Some heap implementations waste a lot of memory when faced with many small allocations.
Definition at line 79 of file shared_ptr.h.
T* o2_int_shared_ptr< T >::subject [private] |
Documentation from Aegis:
The subject instance variable is used to remember the location of the object being reference counted. By having it separate from the reference count, we can skip one indirection.
Definition at line 90 of file shared_ptr.h.
Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).