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

A very simple RAII pointer. More...

#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...
 

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.

Member Typedef Documentation

◆ element_type

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

◆ ScopedPtr()

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

Constructor.

Definition at line 38 of file ScopedPtr.h.

◆ ~ScopedPtr()

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

◆ reset()

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.

◆ operator*()

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

Dereference.

Definition at line 63 of file ScopedPtr.h.

◆ operator->()

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

Member access.

Definition at line 67 of file ScopedPtr.h.

◆ get()

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

Return enclosed built-in pointer.

Definition at line 71 of file ScopedPtr.h.

Referenced by Util::isNull().


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