BLOCXX_NAMESPACE::AutoPtrVec< X > Class Template Reference

The AutoPtrVec class provides a simple class for smart pointers to a dynamically allocated array of objects. More...

#include <AutoPtr.hpp>

List of all members.

Public Types

typedef X element_type

Public Member Functions

 AutoPtrVec (X *p=0)
 Construct a new AutoPtrVec object that assumes ownership of a given array pointer.
 ~AutoPtrVec ()
 Destroy this AutoPtrVec object and the array it points to.
AutoPtrVecoperator= (X *p)
 Assignment operator Assign a new array pointer to this AutoPtrVec object.
X & operator * () const
X * operator-> () const
X & operator[] (unsigned n)
const X & operator[] (unsigned i) const
X * get () const
X * release ()
 Release ownership of the underlying array.
void reset (X *p=0)
 Delete the array the underlying pointer points to and take ownership of a new array pointer.

Private Member Functions

 AutoPtrVec (const AutoPtrVec &a)
AutoPtrVecoperator= (const AutoPtrVec &a)

Private Attributes

X * _ptr


Detailed Description

template<class X>
class BLOCXX_NAMESPACE::AutoPtrVec< X >

The AutoPtrVec class provides a simple class for smart pointers to a dynamically allocated array of objects.

It stores a pointer to the array obtained by way of the new operator and deletes the array when the AutoPtrVec object is destroyed. The AutoPtrVec class provides semantics of strict ownership. After construction an AutoPtrVec object owns the array whose pointer it holds. When an instantiation of AutoPtrVec is copied, ownership of the array is transferred to the destination AutoPtrVec. The behavior is undefined if more than one instantiation of AutoPtrVec owns the same array at the same time.

Definition at line 183 of file AutoPtr.hpp.


Member Typedef Documentation

template<class X>
typedef X BLOCXX_NAMESPACE::AutoPtrVec< X >::element_type
 

Definition at line 193 of file AutoPtr.hpp.


Constructor & Destructor Documentation

template<class X>
BLOCXX_NAMESPACE::AutoPtrVec< X >::AutoPtrVec const AutoPtrVec< X > &  a  )  [private]
 

template<class X>
BLOCXX_NAMESPACE::AutoPtrVec< X >::AutoPtrVec X *  p = 0  )  [inline, explicit]
 

Construct a new AutoPtrVec object that assumes ownership of a given array pointer.

Parameters:
p pointer to the array.

Definition at line 263 of file AutoPtr.hpp.

template<class X>
BLOCXX_NAMESPACE::AutoPtrVec< X >::~AutoPtrVec  ) 
 

Destroy this AutoPtrVec object and the array it points to.

Definition at line 277 of file AutoPtr.hpp.

References BLOCXX_NAMESPACE::AutoPtrVec< X >::_ptr.


Member Function Documentation

template<class X>
X * BLOCXX_NAMESPACE::AutoPtrVec< X >::get  )  const
 

Returns:
The underlying pointer to the array.

Definition at line 296 of file AutoPtr.hpp.

References BLOCXX_NAMESPACE::AutoPtrVec< X >::_ptr.

Referenced by BLOCXX_NAMESPACE::String::concat(), BLOCXX_NAMESPACE::String::format(), BLOCXX_NAMESPACE::UnnamedPipe::readString(), and BLOCXX_NAMESPACE::String::String().

template<class X>
X & BLOCXX_NAMESPACE::AutoPtrVec< X >::operator *  )  const
 

Returns:
A reference to the object to which the underlying held pointer points.

Definition at line 284 of file AutoPtr.hpp.

References BLOCXX_NAMESPACE::AutoPtrVec< X >::_ptr.

template<class X>
X * BLOCXX_NAMESPACE::AutoPtrVec< X >::operator->  )  const
 

Returns:
The underlying held pointer.

Definition at line 287 of file AutoPtr.hpp.

References BLOCXX_NAMESPACE::AutoPtrVec< X >::_ptr.

template<class X>
AutoPtrVec< X > & BLOCXX_NAMESPACE::AutoPtrVec< X >::operator= X *  p  ) 
 

Assignment operator Assign a new array pointer to this AutoPtrVec object.

If this AutoPtrVec object points to another array before this assignment, then that array will be destroyed first.

Parameters:
p The new array pointer this AutoPtrVec object will own.
Returns:
A reference to this AutoPtrVec object.

Definition at line 266 of file AutoPtr.hpp.

References BLOCXX_NAMESPACE::AutoPtrVec< X >::_ptr, and BLOCXX_NAMESPACE::AutoPtrVec< X >::reset().

template<class X>
AutoPtrVec& BLOCXX_NAMESPACE::AutoPtrVec< X >::operator= const AutoPtrVec< X > &  a  )  [private]
 

template<class X>
const X & BLOCXX_NAMESPACE::AutoPtrVec< X >::operator[] unsigned  i  )  const
 

Returns:
A read only reference to the nth element of the array owned by this AutoPtrVec object.

Definition at line 293 of file AutoPtr.hpp.

References BLOCXX_NAMESPACE::AutoPtrVec< X >::_ptr.

template<class X>
X & BLOCXX_NAMESPACE::AutoPtrVec< X >::operator[] unsigned  n  ) 
 

Returns:
A read/write reference to the nth element of the array owned by this AutoPtrVec object.

Definition at line 290 of file AutoPtr.hpp.

References BLOCXX_NAMESPACE::AutoPtrVec< X >::_ptr.

template<class X>
X * BLOCXX_NAMESPACE::AutoPtrVec< X >::release  ) 
 

Release ownership of the underlying array.

Returns:
The value of the underlying held array pointer before the call to release.

Definition at line 299 of file AutoPtr.hpp.

References BLOCXX_NAMESPACE::AutoPtrVec< X >::_ptr.

Referenced by BLOCXX_NAMESPACE::UnnamedPipe::readString().

template<class X>
void BLOCXX_NAMESPACE::AutoPtrVec< X >::reset X *  p = 0  ) 
 

Delete the array the underlying pointer points to and take ownership of a new array pointer.

This is similar to the assignment operator.

Parameters:
p The array pointer this AutoPtr will take ownership of.

Definition at line 307 of file AutoPtr.hpp.

References BLOCXX_NAMESPACE::AutoPtrVec< X >::_ptr.

Referenced by BLOCXX_NAMESPACE::AutoPtrVec< X >::operator=().


Member Data Documentation

template<class X>
X* BLOCXX_NAMESPACE::AutoPtrVec< X >::_ptr [private]
 

Definition at line 186 of file AutoPtr.hpp.

Referenced by BLOCXX_NAMESPACE::AutoPtrVec< X >::get(), BLOCXX_NAMESPACE::AutoPtrVec< X >::operator *(), BLOCXX_NAMESPACE::AutoPtrVec< X >::operator->(), BLOCXX_NAMESPACE::AutoPtrVec< X >::operator=(), BLOCXX_NAMESPACE::AutoPtrVec< X >::operator[](), BLOCXX_NAMESPACE::AutoPtrVec< X >::release(), BLOCXX_NAMESPACE::AutoPtrVec< X >::reset(), and BLOCXX_NAMESPACE::AutoPtrVec< X >::~AutoPtrVec().


The documentation for this class was generated from the following file:
Generated on Fri Jun 16 15:39:10 2006 for blocxx by  doxygen 1.4.6