golib  0.5
goAutoPtr< T > Class Template Reference

"Smart pointer". Wrapper that automatically deletes its managed pointer when the internal reference count is zero and the last goAutoPtr is deleted. More...

#include <goautoptr.h>

Public Member Functions

 goAutoPtr (T *p)
 Initialises a new pointer and sets the reference count to 1. More...
 
void set (T *p)
 
T * get ()
 
const T * get () const
 
void reset ()
 Reset the pointer and reference count. Decrements the current reference count, if a pointer is set, and deletes the pointer if the reference is 0.
 
 ~goAutoPtr ()
 Decrements the reference count and, if it is 0, deletes the pointer (if any).
 
 goAutoPtr (const goAutoPtr< T > &other)
 Reference the same object as other. More...
 
template<class To >
 goAutoPtr (const goAutoPtr< To > &other)
 
goRRefPtr< void > * getRRefPtr ()
 
const goRRefPtr< void > * getRRefPtr () const
 
goAutoPtr< T > & operator= (const goAutoPtr< T > &other)
 
template<class To >
goAutoPtr< T > & operator= (const goAutoPtr< To > &other)
 
bool isNull () const
 
template<class To >
bool operator== (const goAutoPtr< To > &other) const
 
template<class To >
bool operator!= (const goAutoPtr< To > &other) const
 
bool operator== (const T *p) const
 
bool operator!= (const T *p) const
 
T & operator* ()
 The usual unary operator*(). More...
 
T * operator-> ()
 The usual operator->(). More...
 
 operator T* ()
 
 operator const T * () const
 

Detailed Description

template<class T>
class goAutoPtr< T >

"Smart pointer". Wrapper that automatically deletes its managed pointer when the internal reference count is zero and the last goAutoPtr is deleted.

Examples
sumproduct/sp.cpp.

Constructor & Destructor Documentation

◆ goAutoPtr() [1/2]

template<class T>
goAutoPtr< T >::goAutoPtr ( T *  p)
inline

Initialises a new pointer and sets the reference count to 1.

Parameters
pPointer to be managed.

◆ goAutoPtr() [2/2]

template<class T>
goAutoPtr< T >::goAutoPtr ( const goAutoPtr< T > &  other)
inline

Reference the same object as other.

Note
The const classifier is only here to ensure that this class works with lists and the like. No RefPtr is const.
Parameters
otherOther auto ptr.

Member Function Documentation

◆ operator*()

template<class T>
T& goAutoPtr< T >::operator* ( )
inline

The usual unary operator*().

Returns
Reference to the managed object.

◆ operator->()

template<class T>
T* goAutoPtr< T >::operator-> ( )
inline

The usual operator->().

Returns
Pointer to the managed object.

◆ operator=()

template<class T>
template<class To >
goAutoPtr<T>& goAutoPtr< T >::operator= ( const goAutoPtr< To > &  other)
inline
Note
The const classifier is only here to ensure that this class works with lists and the like. No RefPtr is const.
Bug:
SEE CODE!
Parameters
other
Returns

The documentation for this class was generated from the following file: