blocxx
Public Types | Public Member Functions | Private Member Functions | Private Attributes

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 184 of file AutoPtr.hpp.


Member Typedef Documentation

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

Definition at line 194 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:
ppointer to the array.

Definition at line 264 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 278 of file AutoPtr.hpp.


Member Function Documentation

template<class X >
X * BLOCXX_NAMESPACE::AutoPtrVec< X >::get ( ) const
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 285 of file AutoPtr.hpp.

template<class X >
X * BLOCXX_NAMESPACE::AutoPtrVec< X >::operator-> ( ) const
Returns:
The underlying held pointer.

Definition at line 288 of file AutoPtr.hpp.

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:
pThe new array pointer this AutoPtrVec object will own.
Returns:
A reference to this AutoPtrVec object.

Definition at line 267 of file AutoPtr.hpp.

template<class X>
AutoPtrVec& BLOCXX_NAMESPACE::AutoPtrVec< X >::operator= ( const AutoPtrVec< X > &  a) [private]
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 291 of file AutoPtr.hpp.

References i.

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 294 of file AutoPtr.hpp.

References i.

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 300 of file AutoPtr.hpp.

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:
pThe array pointer this AutoPtr will take ownership of.

Definition at line 308 of file AutoPtr.hpp.


Member Data Documentation

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

Definition at line 187 of file AutoPtr.hpp.


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