Simpatico  v1.10
List of all members | Public Types | Public Member Functions
Util::ScopedPtr< T > Class Template Reference

Detailed Description

template<typename T>
class Util::ScopedPtr< T >

A very simple RAII pointer.

A ScopedPtr mimics a built-in pointer, except that guarantees destruction of the object to which it points when the ScopedPtr goes out of scope. It accepts ownership of a built-in pointer either upon construction or by the reset() method, and deletes the associated object in its destructor. A ScopedPtr cannot be copy constructed or assigned.

Similar to boost::scoped_ptr, with minor differences. It takes the same amount of memory as a built-in pointer, and should be equally fast.

Definition at line 29 of file ScopedPtr.h.

#include <ScopedPtr.h>

Public Types

typedef T element_type
 Type of object pointed to. More...
 

Public Member Functions

 ScopedPtr (T *p=0)
 Constructor. More...
 
 ~ScopedPtr ()
 Destructor, destroys object pointed to, if any. More...
 
void reset (T *p=0)
 Acquire ownership of a built-in pointer. More...
 
T & operator* () const
 Dereference. More...
 
T * operator-> () const
 Member access. More...
 
T * get () const
 Return enclosed built-in pointer. More...
 

Member Typedef Documentation

template<typename T>
typedef T Util::ScopedPtr< T >::element_type

Type of object pointed to.

Definition at line 35 of file ScopedPtr.h.

Constructor & Destructor Documentation

template<typename T>
Util::ScopedPtr< T >::ScopedPtr ( T *  p = 0)
inlineexplicit

Constructor.

Definition at line 38 of file ScopedPtr.h.

Referenced by Util::ScopedPtr< T >::get().

template<typename T>
Util::ScopedPtr< T >::~ScopedPtr ( )
inline

Destructor, destroys object pointed to, if any.

Definition at line 42 of file ScopedPtr.h.

Member Function Documentation

template<typename T>
void Util::ScopedPtr< T >::reset ( T *  p = 0)
inline

Acquire ownership of a built-in pointer.

Parameters
pbuilt-in pointer to acquire.

Definition at line 54 of file ScopedPtr.h.

template<typename T>
T& Util::ScopedPtr< T >::operator* ( ) const
inline

Dereference.

Definition at line 63 of file ScopedPtr.h.

template<typename T>
T* Util::ScopedPtr< T >::operator-> ( ) const
inline

Member access.

Definition at line 67 of file ScopedPtr.h.

template<typename T>
T* Util::ScopedPtr< T >::get ( ) const
inline

Return enclosed built-in pointer.

Definition at line 71 of file ScopedPtr.h.

References Util::ScopedPtr< T >::ScopedPtr().

Referenced by Util::isNull().


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