w_auto_delete_t< T > Class Template Reference

List of all members.

Detailed Description

template<class T>
class w_auto_delete_t< T >

Delete object when this leaves scope (a la STL auto_ptr).

This class is used to ensure that a "new"ed object of type T will be "delete"d when the scope is closed. During destruction, automatically call "delete" on the pointer supplied during construction.

eg. f()

    {
          int* p = new int;
        if (!p)  return OUTOFMEMORY;
        w_auto_delete_t<int> autodel(p);

         ... do work ...

        if (error)  {    // no need to call delete p
        return error;
        }

        // no need to call delete p
        return OK;
    }

delete p will be called by the autodel object. Thus users do not need to code 'delete p' explicitly, and can be assured that p will be deleted when the scope in which autodel was constructed is closed.

This code predates the STL.

Definition at line 94 of file w_autodel.h.

Public Member Functions

NORET w_auto_delete_t ()
NORET w_auto_delete_t (T *t)
NORET ~w_auto_delete_t ()
w_auto_delete_tset (T *t)
T * operator-> ()
T & operator * ()
 operator T * ()
T const * operator-> () const
T const & operator * () const
 operator T const * () const


The documentation for this class was generated from the following file:
Generated on Wed Jul 7 17:22:43 2010 for Shore Storage Manager by  doxygen 1.4.7