src
Public Member Functions | List of all members
re2c::smart_ptr< T > Class Template Reference

#include <smart_ptr.h>

Public Member Functions

 smart_ptr (T *p=0)
 
 smart_ptr (const smart_ptr< T > &p) throw ()
 
 ~smart_ptr ()
 
smart_ptr< T > & operator= (const smart_ptr< T > &p)
 
T & operator* () const
 
T * operator-> () const
 

Detailed Description

template<class T>
class re2c::smart_ptr< T >

Definition at line 8 of file smart_ptr.h.

Constructor & Destructor Documentation

template<class T>
re2c::smart_ptr< T >::smart_ptr ( T *  p = 0)
inlineexplicit

Definition at line 15 of file smart_ptr.h.

16  : ptr(p), count(new long(1)) {}
template<class T>
re2c::smart_ptr< T >::smart_ptr ( const smart_ptr< T > &  p)
throw (
)
inline

Definition at line 18 of file smart_ptr.h.

19  : ptr(p.ptr), count(p.count)
20  {
21  ++*count;
22  }
template<class T>
re2c::smart_ptr< T >::~smart_ptr ( )
inline

Definition at line 24 of file smart_ptr.h.

25  {
26  dispose();
27  }

Member Function Documentation

template<class T>
T& re2c::smart_ptr< T >::operator* ( ) const
inline

Definition at line 41 of file smart_ptr.h.

42  {
43  return *ptr;
44  }
template<class T>
T* re2c::smart_ptr< T >::operator-> ( ) const
inline

Definition at line 46 of file smart_ptr.h.

47  {
48  return ptr;
49  }
template<class T>
smart_ptr<T>& re2c::smart_ptr< T >::operator= ( const smart_ptr< T > &  p)
inline

Definition at line 29 of file smart_ptr.h.

30  {
31  if (this != &p)
32  {
33  dispose();
34  ptr = p.ptr;
35  count = p.count;
36  ++*count;
37  }
38  return *this;
39  }

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