WRAPPERS::auto_ary< T > Class Template Reference

Similar to auto_ptr but only to be used for arrays of objects. More...

#include <Wrappers.h>

Collaboration diagram for WRAPPERS::auto_ary< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 auto_ary (T *ptr=0)
 An auto_ary is usually constructed from a raw pointer.
 auto_ary (auto_ary< T > &o)
 An auto_ary can be constructed from another auto_ary.
 ~auto_ary ()
 When the auto_ary goes out of scope, the object it owns is deleted.
auto_ary< T > & operator= (auto_ary< T > &rhs)
 auto_ary assignment operator.
const T & operator[] (int i) const
 array subscript read-only access.
T & operator[] (int i)
 array subscript write access.
T * get () const
 Bypassing the smart pointer.

Private Attributes

T * m_ptr

Detailed Description

template<typename T>
class WRAPPERS::auto_ary< T >

Similar to auto_ptr but only to be used for arrays of objects.

An auto_ary owns the object it holds a pointer to. Copying an auto_ary copies the pointer and transfers ownership to the destination. If more than one auto_ary owns the same object at the same time the behavior of the program is undefined.


Constructor & Destructor Documentation

template<typename T>
WRAPPERS::auto_ary< T >::auto_ary ( T *  ptr = 0  )  [inline, explicit]

An auto_ary is usually constructed from a raw pointer.

Parameters:
ptr A pointer (defaults to NULL).
This object now owns the object pointed to by ptr.

template<typename T>
WRAPPERS::auto_ary< T >::auto_ary ( auto_ary< T > &  o  )  [inline]

An auto_ary can be constructed from another auto_ary.

Parameters:
o Another auto_ary of the same type.
This object now owns the object previously owned by o, which has given up ownsership.

template<typename T>
WRAPPERS::auto_ary< T >::~auto_ary (  )  [inline]

When the auto_ary goes out of scope, the object it owns is deleted.

If it no longer owns anything (i.e., get() is NULL), then this has no effect.


Member Function Documentation

template<typename T>
T* WRAPPERS::auto_ary< T >::get (  )  const [inline]

Bypassing the smart pointer.

Returns:
The raw pointer being managed.
You can get a copy of the pointer that this object owns, for situations such as passing to a function which only accepts a raw pointer.

Note:
This auto_ary still owns the memory.

template<typename T>
auto_ary<T>& WRAPPERS::auto_ary< T >::operator= ( auto_ary< T > &  rhs  )  [inline]

auto_ary assignment operator.

Parameters:
rhs Another auto_ary the same type
This object now owns the object previously owned by rhs, which has given up ownsership. The object that this one used to own and track has been deleted.

template<typename T>
T& WRAPPERS::auto_ary< T >::operator[] ( int  i  )  [inline]

array subscript write access.

Parameters:
i the array subscript index.
No bounds checking is done.

template<typename T>
const T& WRAPPERS::auto_ary< T >::operator[] ( int  i  )  const [inline]

array subscript read-only access.

Parameters:
i the array subscript index.
No bounds checking is done.


Member Data Documentation

template<typename T>
T* WRAPPERS::auto_ary< T >::m_ptr [private]


The documentation for this class was generated from the following file:
Generated on Sun Mar 11 15:33:27 2007 for MetalWarriors by  doxygen 1.4.7