L4Re - L4 Runtime Environment
cxx::Auto_ptr< T > Class Template Reference

Smart pointer with automatic deletion. More...

+ Collaboration diagram for cxx::Auto_ptr< T >:

Public Types

typedef T Ref_type
 The referenced type. More...
 

Public Member Functions

 Auto_ptr (T *p=0) throw ()
 Construction by assignment of a normal pointer. More...
 
 Auto_ptr (Auto_ptr const &o) throw ()
 Copy construction, releases the original pointer. More...
 
Auto_ptroperator= (Auto_ptr const &o) throw ()
 Assignment from another smart pointer. More...
 
 ~Auto_ptr () throw ()
 Destruction, shall delete the object. More...
 
T & operator* () const throw ()
 Dereference the pointer. More...
 
T * operator-> () const throw ()
 Member access for the object. More...
 
T * get () const throw ()
 Get the normal pointer. More...
 
T * release () throw ()
 Release the object and get the normal pointer back. More...
 
void reset (T *p=0) throw ()
 Delete the object and reset the smart pointer to NULL.
 
 operator Priv_type * () const throw ()
 Operator for if (!ptr) .... More...
 

Detailed Description

template<typename T>
class cxx::Auto_ptr< T >

Smart pointer with automatic deletion.

Template Parameters
TThe type of the referenced object.

This smart pointer calls the delete operator when the destructor is called. This has the effect that the object the pointer points to will be deleted when the pointer goes out of scope, or a new value gets assigned. The smart pointer provides a release() method to get a normal pointer to the object and set the smart pointer to NULL.

Definition at line 36 of file auto_ptr.

Member Typedef Documentation

◆ Ref_type

template<typename T >
typedef T cxx::Auto_ptr< T >::Ref_type

The referenced type.

Definition at line 41 of file auto_ptr.

Constructor & Destructor Documentation

◆ Auto_ptr() [1/2]

template<typename T >
cxx::Auto_ptr< T >::Auto_ptr ( T *  p = 0)
throw (
)
inlineexplicit

Construction by assignment of a normal pointer.

Parameters
pThe pointer to the object

Definition at line 51 of file auto_ptr.

◆ Auto_ptr() [2/2]

template<typename T >
cxx::Auto_ptr< T >::Auto_ptr ( Auto_ptr< T > const &  o)
throw (
)
inline

Copy construction, releases the original pointer.

Parameters
oThe smart pointer, which shall be copied and released.

Definition at line 57 of file auto_ptr.

◆ ~Auto_ptr()

template<typename T >
cxx::Auto_ptr< T >::~Auto_ptr ( )
throw (
)
inline

Destruction, shall delete the object.

Definition at line 76 of file auto_ptr.

Member Function Documentation

◆ get()

template<typename T >
T* cxx::Auto_ptr< T >::get ( ) const
throw (
)
inline

Get the normal pointer.

Attention
This function will not release the object, the object will be deleted by the smart pointer.

Definition at line 90 of file auto_ptr.

◆ operator Priv_type *()

template<typename T >
cxx::Auto_ptr< T >::operator Priv_type * ( ) const
throw (
)
inline

Operator for if (!ptr) ....

Definition at line 110 of file auto_ptr.

◆ operator*()

template<typename T >
T& cxx::Auto_ptr< T >::operator* ( ) const
throw (
)
inline

Dereference the pointer.

Definition at line 80 of file auto_ptr.

◆ operator->()

template<typename T >
T* cxx::Auto_ptr< T >::operator-> ( ) const
throw (
)
inline

Member access for the object.

Definition at line 83 of file auto_ptr.

◆ operator=()

template<typename T >
Auto_ptr& cxx::Auto_ptr< T >::operator= ( Auto_ptr< T > const &  o)
throw (
)
inline

Assignment from another smart pointer.

Parameters
oThe source for the assignment (will be released).

Definition at line 65 of file auto_ptr.

◆ release()

template<typename T >
T* cxx::Auto_ptr< T >::release ( )
throw (
)
inline

Release the object and get the normal pointer back.

After calling this function the smart pointer will point to NULL and the object will not be deleted by the pointer anymore.

Definition at line 98 of file auto_ptr.


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