TC::ScopedPtr< T, DELETER > Class Template Reference
[Base Classes and Functions]

A class whose instances act like pointers and delete the pointer when the instance goes out of scope. More...

#include <TCScopedPtr.h>

Collaboration diagram for TC::ScopedPtr< T, DELETER >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef T *ThisType::* unspecified_bool_type

Public Member Functions

 ScopedPtr ()
 Construct the object pointing to a 0 object.
 ScopedPtr (T *ptr)
 Construct the object pointing to a specified object.
 ScopedPtr (std::auto_ptr< T > ptr)
 Construct the object pointing to a specified std::auto_ptr.
 ~ScopedPtr ()
 Destructor deletes the pointer.
const T * operator-> () const
 User define conversion to the const Template pointer type.
T * operator-> ()
 User define conversion to the Template pointer type.
 operator unspecified_bool_type () const
 User define conversion for if like "if (pointer)".
bool operator! () const
 User define conversion for if like "if (!pointer)".

Private Types

typedef ScopedPtr< T > ThisType

Private Attributes

T * m_ptr


Detailed Description

template<class T, class DELETER = CheckedDelete>
class TC::ScopedPtr< T, DELETER >

A class whose instances act like pointers and delete the pointer when the instance goes out of scope.

TC::ScopedPtr mimics a built-in pointer except that it guarantees deletion of the object pointed to on destruction of the TC::ScopedPtr TC::ScopedPtr is a simple solution for simple needs; use TC::SharedPtr or std::auto_ptr if your needs are more complex.

Definition at line 65 of file TCScopedPtr.h.


Member Typedef Documentation

template<class T , class DELETER = CheckedDelete>
typedef ScopedPtr<T> TC::ScopedPtr< T, DELETER >::ThisType [private]

Definition at line 68 of file TCScopedPtr.h.

template<class T , class DELETER = CheckedDelete>
typedef T* ThisType::* TC::ScopedPtr< T, DELETER >::unspecified_bool_type

Definition at line 86 of file TCScopedPtr.h.


Constructor & Destructor Documentation

template<class T , class DELETER = CheckedDelete>
TC::ScopedPtr< T, DELETER >::ScopedPtr (  )  [inline]

Construct the object pointing to a 0 object.

Definition at line 72 of file TCScopedPtr.h.

template<class T , class DELETER = CheckedDelete>
TC::ScopedPtr< T, DELETER >::ScopedPtr ( T *  ptr  )  [inline, explicit]

Construct the object pointing to a specified object.

Definition at line 74 of file TCScopedPtr.h.

template<class T , class DELETER = CheckedDelete>
TC::ScopedPtr< T, DELETER >::ScopedPtr ( std::auto_ptr< T >  ptr  )  [inline, explicit]

Construct the object pointing to a specified std::auto_ptr.

Definition at line 76 of file TCScopedPtr.h.

template<class T , class DELETER = CheckedDelete>
TC::ScopedPtr< T, DELETER >::~ScopedPtr (  )  [inline]

Destructor deletes the pointer.

Definition at line 79 of file TCScopedPtr.h.

References TC::ScopedPtr< T, DELETER >::m_ptr.


Member Function Documentation

template<class T , class DELETER = CheckedDelete>
const T* TC::ScopedPtr< T, DELETER >::operator-> (  )  const [inline]

User define conversion to the const Template pointer type.

Definition at line 82 of file TCScopedPtr.h.

References TC::ScopedPtr< T, DELETER >::m_ptr.

template<class T , class DELETER = CheckedDelete>
T* TC::ScopedPtr< T, DELETER >::operator-> (  )  [inline]

User define conversion to the Template pointer type.

Definition at line 84 of file TCScopedPtr.h.

References TC::ScopedPtr< T, DELETER >::m_ptr.

template<class T , class DELETER = CheckedDelete>
TC::ScopedPtr< T, DELETER >::operator unspecified_bool_type (  )  const [inline]

User define conversion for if like "if (pointer)".

Definition at line 88 of file TCScopedPtr.h.

References TC::ScopedPtr< T, DELETER >::m_ptr.

template<class T , class DELETER = CheckedDelete>
bool TC::ScopedPtr< T, DELETER >::operator! (  )  const [inline]

User define conversion for if like "if (!pointer)".

Definition at line 94 of file TCScopedPtr.h.

References TC::ScopedPtr< T, DELETER >::m_ptr.


Member Data Documentation

template<class T , class DELETER = CheckedDelete>
T* TC::ScopedPtr< T, DELETER >::m_ptr [private]


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

Copyright (c) Thomas Goessler 2003 - 2008