Remake
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Classes | Public Member Functions | Public Attributes | List of all members
ref_ptr< T > Struct Template Reference

Classes

struct  content
 

Public Member Functions

 ref_ptr ()
 
 ref_ptr (T const &t)
 
 ref_ptr (ref_ptr const &p)
 
 ~ref_ptr ()
 
ref_ptroperator= (ref_ptr const &p)
 
T & operator* () const
 
T * operator-> () const
 

Public Attributes

contentptr
 

Detailed Description

template<class T>
struct ref_ptr< T >

Reference-counted shared object.

Note
The default constructor delays the creation of the object until it is first dereferenced.

Definition at line 466 of file remake.cpp.

Constructor & Destructor Documentation

template<class T>
ref_ptr< T >::ref_ptr ( )
inline

Definition at line 476 of file remake.cpp.

476 : ptr(NULL) {}
content * ptr
Definition: remake.cpp:475
template<class T>
ref_ptr< T >::ref_ptr ( T const &  t)
inline

Definition at line 477 of file remake.cpp.

477 : ptr(new content(t)) {}
content * ptr
Definition: remake.cpp:475
template<class T>
ref_ptr< T >::ref_ptr ( ref_ptr< T > const &  p)
inline

Definition at line 478 of file remake.cpp.

478 : ptr(p.ptr) { if (ptr) ++ptr->cnt; }
content * ptr
Definition: remake.cpp:475
template<class T>
ref_ptr< T >::~ref_ptr ( )
inline

Definition at line 479 of file remake.cpp.

479 { if (ptr && --ptr->cnt == 0) delete ptr; }
content * ptr
Definition: remake.cpp:475

Member Function Documentation

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

Definition at line 488 of file remake.cpp.

489  {
490  if (!ptr) ptr = new content;
491  return ptr->val;
492  }
content * ptr
Definition: remake.cpp:475
template<class T>
T* ref_ptr< T >::operator-> ( ) const
inline

Definition at line 493 of file remake.cpp.

493 { return &**this; }
template<class T>
ref_ptr& ref_ptr< T >::operator= ( ref_ptr< T > const &  p)
inline

Definition at line 480 of file remake.cpp.

481  {
482  if (ptr == p.ptr) return *this;
483  if (ptr && --ptr->cnt == 0) delete ptr;
484  ptr = p.ptr;
485  if (ptr) ++ptr->cnt;
486  return *this;
487  }
content * ptr
Definition: remake.cpp:475

Member Data Documentation

template<class T>
content* ref_ptr< T >::ptr
mutable

Definition at line 475 of file remake.cpp.

Referenced by ref_ptr< T >::operator=(), and ref_ptr< T >::~ref_ptr().


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