auto_vec< T > Class Template Reference

#include <cddefines.h>

Collaboration diagram for auto_vec< T >:

Collaboration graph
[legend]

Public Types

typedef T element_type

Public Member Functions

 auto_vec (element_type *p=NULL) throw ()
 auto_vec (auto_vec &p) throw ()
auto_vecoperator= (auto_vec &p) throw ()
 ~auto_vec () throw ()
element_typeoperator[] (ptrdiff_t n) const throw ()
element_typeget () const throw ()
element_typedata () const throw ()
element_typerelease () throw ()
void reset (element_type *p=NULL) throw ()
 auto_vec (auto_vec_ref< element_type > r) throw ()
auto_vecoperator= (auto_vec_ref< element_type > r) throw ()
 operator auto_vec_ref () throw ()

Private Attributes

T * ptr

Data Structures

struct  auto_vec_ref

Detailed Description

template<class T>
class auto_vec< T >

auto_vec: a smart pointer to allocated arrays which maintains strict ownership. the implementation here largely follows the ISO/ANSI C++98 standard for auto_ptr

NB1 - the operator[] and data() methods were added and are not part of the standard

NB2 - operator* and operator-> have been omitted as they are not useful for vectors

NB3 - the class has been altered to disallow assigning pointers of a different type, i.e., auto_vec<BaseClass> p( new DerivedClass[10] ) is NOT allowed. This is done because BaseClass and DerivedClass often have different sizes, and hence using them like this in vectors is error-prone.

NB4 - operator auto_vec<T>() has been omitted because it is only needed to convert an auto_vec<DerivedClass> to auto_vec<BaseClass>.

This is written in the standards draft (with auto_ptr replaced by auto_vec):

1 Template auto_vec holds a pointer to an array object obtained via new and deletes that object when it itself is destroyed (such as when leaving block scope 6.7).

2 Template auto_vec_ref holds a reference to an auto_vec. It is used by the auto_vec conversions to allow auto_vec objects to be passed to and returned from functions.

Definition at line 991 of file cddefines.h.


Member Typedef Documentation

template<class T>
typedef T auto_vec< T >::element_type

Definition at line 1007 of file cddefines.h.


Constructor & Destructor Documentation

template<class T>
auto_vec< T >::auto_vec ( element_type p = NULL  )  throw () [inline, explicit]

Definition at line 1011 of file cddefines.h.

References auto_vec< T >::ptr.

template<class T>
auto_vec< T >::auto_vec ( auto_vec< T > &  p  )  throw () [inline]

Definition at line 1015 of file cddefines.h.

References auto_vec< T >::ptr.

template<class T>
auto_vec< T >::~auto_vec (  )  throw () [inline]

Definition at line 1024 of file cddefines.h.

References auto_vec< T >::ptr.

template<class T>
auto_vec< T >::auto_vec ( auto_vec_ref< element_type r  )  throw () [inline]

Definition at line 1061 of file cddefines.h.

References auto_vec< T >::ptr.


Member Function Documentation

template<class T>
element_type* auto_vec< T >::data (  )  const throw () [inline]

Definition at line 1040 of file cddefines.h.

References auto_vec< T >::ptr.

template<class T>
element_type* auto_vec< T >::get (  )  const throw () [inline]

Definition at line 1035 of file cddefines.h.

References auto_vec< T >::ptr.

template<class T>
auto_vec< T >::operator auto_vec_ref (  )  throw () [inline]

Definition at line 1074 of file cddefines.h.

References auto_vec< T >::release().

Here is the call graph for this function:

template<class T>
auto_vec& auto_vec< T >::operator= ( auto_vec_ref< element_type r  )  throw () [inline]

Definition at line 1065 of file cddefines.h.

References auto_vec< T >::ptr.

template<class T>
auto_vec& auto_vec< T >::operator= ( auto_vec< T > &  p  )  throw () [inline]

Definition at line 1019 of file cddefines.h.

References auto_vec< T >::reset().

Here is the call graph for this function:

template<class T>
element_type& auto_vec< T >::operator[] ( ptrdiff_t  n  )  const throw () [inline]

Definition at line 1031 of file cddefines.h.

References auto_vec< T >::ptr.

template<class T>
element_type* auto_vec< T >::release (  )  throw () [inline]

Definition at line 1044 of file cddefines.h.

References auto_vec< T >::ptr.

Referenced by auto_vec< T >::operator auto_vec_ref().

template<class T>
void auto_vec< T >::reset ( element_type p = NULL  )  throw () [inline]

Definition at line 1050 of file cddefines.h.

References auto_vec< T >::ptr.

Referenced by auto_vec< T >::operator=().


Field Documentation

template<class T>
T* auto_vec< T >::ptr [private]

Definition at line 993 of file cddefines.h.

Referenced by auto_vec< T >::auto_vec(), auto_vec< T >::data(), auto_vec< T >::get(), auto_vec< T >::operator=(), auto_vec< T >::operator[](), auto_vec< T >::release(), auto_vec< T >::reset(), and auto_vec< T >::~auto_vec().


The documentation for this class was generated from the following file:
Generated on Mon Feb 16 12:14:12 2009 for cloudy by  doxygen 1.4.7