blocxx
|
The AutoPtrVec class provides a simple class for smart pointers to a dynamically allocated array of objects. More...
#include <AutoPtr.hpp>
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. | |
AutoPtrVec & | operator= (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) | |
AutoPtrVec & | operator= (const AutoPtrVec &a) |
Private Attributes | |
X * | _ptr |
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.
typedef X BLOCXX_NAMESPACE::AutoPtrVec< X >::element_type |
Definition at line 194 of file AutoPtr.hpp.
BLOCXX_NAMESPACE::AutoPtrVec< X >::AutoPtrVec | ( | const AutoPtrVec< X > & | a | ) | [private] |
BLOCXX_NAMESPACE::AutoPtrVec< X >::AutoPtrVec | ( | X * | p = 0 | ) | [inline, explicit] |
Construct a new AutoPtrVec object that assumes ownership of a given array pointer.
p | pointer to the array. |
Definition at line 264 of file AutoPtr.hpp.
BLOCXX_NAMESPACE::AutoPtrVec< X >::~AutoPtrVec | ( | ) |
Destroy this AutoPtrVec object and the array it points to.
Definition at line 278 of file AutoPtr.hpp.
X * BLOCXX_NAMESPACE::AutoPtrVec< X >::get | ( | ) | const |
Definition at line 297 of file AutoPtr.hpp.
Referenced by BLOCXX_NAMESPACE::String::concat(), BLOCXX_NAMESPACE::FileSystem::createAutoDeleteTempFile(), BLOCXX_NAMESPACE::FileSystem::createTempFile(), BLOCXX_NAMESPACE::String::format(), BLOCXX_NAMESPACE::UnnamedPipe::readString(), BLOCXX_NAMESPACE::Select::selectRWEpoll(), BLOCXX_NAMESPACE::String::String(), and BLOCXX_NAMESPACE::String::tokenize().
X & BLOCXX_NAMESPACE::AutoPtrVec< X >::operator* | ( | ) | const |
Definition at line 285 of file AutoPtr.hpp.
X * BLOCXX_NAMESPACE::AutoPtrVec< X >::operator-> | ( | ) | const |
Definition at line 288 of file AutoPtr.hpp.
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.
p | The new array pointer this AutoPtrVec object will own. |
Definition at line 267 of file AutoPtr.hpp.
AutoPtrVec& BLOCXX_NAMESPACE::AutoPtrVec< X >::operator= | ( | const AutoPtrVec< X > & | a | ) | [private] |
X & BLOCXX_NAMESPACE::AutoPtrVec< X >::operator[] | ( | unsigned | n | ) |
Definition at line 291 of file AutoPtr.hpp.
References i.
const X & BLOCXX_NAMESPACE::AutoPtrVec< X >::operator[] | ( | unsigned | i | ) | const |
Definition at line 294 of file AutoPtr.hpp.
References i.
X * BLOCXX_NAMESPACE::AutoPtrVec< X >::release | ( | ) |
Release ownership of the underlying array.
Definition at line 300 of file AutoPtr.hpp.
Referenced by BLOCXX_NAMESPACE::UnnamedPipe::readString().
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.
p | The array pointer this AutoPtr will take ownership of. |
Definition at line 308 of file AutoPtr.hpp.
X* BLOCXX_NAMESPACE::AutoPtrVec< X >::_ptr [private] |
Definition at line 187 of file AutoPtr.hpp.