SheafSystem  0.0.0.0
sheaf::rc_ptr< T > Class Template Reference

Reference-counted pointer to object of type T. T must be an implementation of concept class rc_any. More...

#include <rc_ptr.h>

Public Member Functions

 rc_ptr (T *xtarget=0)
 Creates a handle for xtarget. More...
 
 rc_ptr (const rc_ptr &xother)
 Copy constructor. More...
 
 ~rc_ptr ()
 Destructor. More...
 
bool operator! () const
 Comparison of _target to null; enables if(!rc_ptr) syntax. More...
 
template<typename U >
bool operator== (const rc_ptr< U > &xother) const
 Equality comparison; enables comparison to rc_ptrs of other types. More...
 
template<typename U >
bool operator!= (const rc_ptr< U > &xother) const
 Not-equality comparison; enables comparison to rc_ptrs of other types. More...
 
rc_ptroperator= (const rc_ptr &xother)
 Assignment from rc_ptr. More...
 
rc_ptroperator= (T *xtarget)
 Assignment from T*. More...
 
T * operator-> () const
 A pointer to the target. More...
 
T & operator* () const
 A reference to the target. More...
 

Friends

bool operator== (const rc_ptr &lhs, const T *rhs)
 True if and only if the target of lhs is rhs. More...
 
bool operator== (const T *lhs, const rc_ptr &rhs)
 True if and only if lhs is the target of rhs. More...
 
bool operator!= (const rc_ptr &lhs, const T *rhs)
 True if and only if the target of lhs is not rhs. More...
 
bool operator!= (const T *lhs, const rc_ptr &rhs)
 True if and only if lhs is not the target of rhs. More...
 
template<typename U >
bool operator== (const rc_ptr &lhs, const U *rhs)
 True if and only if the target of lhs is rhs. More...
 
template<typename U >
bool operator== (const U *lhs, const rc_ptr &rhs)
 True if and only if lhs is the target of rhs. More...
 
template<typename U >
bool operator!= (const rc_ptr &lhs, const U *rhs)
 True if and only if the target of lhs is not rhs. More...
 
template<typename U >
bool operator!= (const U *lhs, const rc_ptr &rhs)
 True if and only if lhs is not the target of rhs. More...
 
bool same_target (const rc_ptr< T > &xp1, const rc_ptr< T > &xp2)
 True if xp1 and xp2 point to the same target. More...
 
size_type target_ref_ct (const rc_ptr< T > &xp)
 The reference count of the target of xp. More...
 

Detailed Description

template<typename T>
class sheaf::rc_ptr< T >

Reference-counted pointer to object of type T. T must be an implementation of concept class rc_any.

Definition at line 47 of file factory_2.h.

Constructor & Destructor Documentation

◆ rc_ptr() [1/2]

template<typename T >
sheaf::rc_ptr< T >::rc_ptr ( T *  xtarget = 0)

Creates a handle for xtarget.

Postcondition
  • (xtarget != 0) ? xtarget->ref_ct() == old_xtarget_ref_ct+1 : true

Definition at line 40 of file rc_ptr.impl.h.

◆ rc_ptr() [2/2]

template<typename T >
sheaf::rc_ptr< T >::rc_ptr ( const rc_ptr< T > &  xother)

Copy constructor.

Postcondition
  • (*this) == xother
  • ( (*this) != 0 ) ? target_ref_ct(*this) == old_target_ref_ct+1 : true

Definition at line 67 of file rc_ptr.impl.h.

References sheaf::rc_ptr< T >::~rc_ptr().

◆ ~rc_ptr()

template<typename T >
sheaf::rc_ptr< T >::~rc_ptr ( )

Destructor.

Definition at line 91 of file rc_ptr.impl.h.

References sheaf::rc_ptr< T >::operator!().

Referenced by sheaf::rc_ptr< T >::rc_ptr().

Member Function Documentation

◆ operator!()

template<typename T >
bool sheaf::rc_ptr< T >::operator! ( ) const

Comparison of _target to null; enables if(!rc_ptr) syntax.

Definition at line 101 of file rc_ptr.impl.h.

References sheaf::rc_ptr< T >::operator==.

Referenced by sheaf::rc_ptr< T >::~rc_ptr().

◆ operator!=()

template<typename T >
template<typename U >
bool sheaf::rc_ptr< T >::operator!= ( const rc_ptr< U > &  xother) const

Not-equality comparison; enables comparison to rc_ptrs of other types.

Definition at line 119 of file rc_ptr.impl.h.

References sheaf::rc_ptr< T >::operator=().

◆ operator*()

template<typename T >
T & sheaf::rc_ptr< T >::operator* ( ) const

A reference to the target.

Precondition
  • (*this) != 0

Definition at line 237 of file rc_ptr.impl.h.

Referenced by sheaf::rc_ptr< T >::operator->().

◆ operator->()

template<typename T >
T * sheaf::rc_ptr< T >::operator-> ( ) const

A pointer to the target.

Precondition
  • (*this) != 0

Definition at line 225 of file rc_ptr.impl.h.

References sheaf::rc_ptr< T >::operator*().

Referenced by sheaf::rc_ptr< T >::operator=().

◆ operator=() [1/2]

template<typename T >
rc_ptr< T > & sheaf::rc_ptr< T >::operator= ( const rc_ptr< T > &  xother)

Assignment from rc_ptr.

Postcondition
  • (*this) == xother
  • old_same_target ? target_ref_ct(*this) == old_this_target_ref_ct : true
  • (!old_same_target && (xother != 0)) ? target_ref_ct(xother) == old_xother_target_ref_ct + 1: true
  • (!old_same_target && (old_this_target_ref_ct > 1)) ? old_this_target->ref_ct() == old_this_target_ref_ct - 1 : true

Definition at line 127 of file rc_ptr.impl.h.

Referenced by sheaf::rc_ptr< T >::operator!=().

◆ operator=() [2/2]

template<typename T >
rc_ptr< T > & sheaf::rc_ptr< T >::operator= ( T *  xtarget)

Assignment from T*.

Postcondition
  • *this == xtarget
  • old_same_target ? target_ref_ct(*this) == old_this_target_ref_ct : true
  • (!old_same_target && (xtarget != 0)) ? target_ref_ct(*this) == old_xtarget_ref_ct + 1 : true
  • (!old_same_target) && (old_this_target_ref_ct > 1) ? old_this_target->ref_ct() == old_this_target_ref_ct - 1 : true

Definition at line 175 of file rc_ptr.impl.h.

References sheaf::rc_ptr< T >::operator->().

◆ operator==()

template<typename T >
template<typename U >
bool sheaf::rc_ptr< T >::operator== ( const rc_ptr< U > &  xother) const

Equality comparison; enables comparison to rc_ptrs of other types.

Definition at line 110 of file rc_ptr.impl.h.

References sheaf::rc_ptr< T >::operator!=.

Friends And Related Function Documentation

◆ operator!= [1/4]

template<typename T>
bool operator!= ( const rc_ptr< T > &  lhs,
const T *  rhs 
)
friend

True if and only if the target of lhs is not rhs.

Definition at line 65 of file rc_ptr.h.

Referenced by sheaf::rc_ptr< T >::operator==().

◆ operator!= [2/4]

template<typename T>
bool operator!= ( const T *  lhs,
const rc_ptr< T > &  rhs 
)
friend

True if and only if lhs is not the target of rhs.

Definition at line 73 of file rc_ptr.h.

◆ operator!= [3/4]

template<typename T>
template<typename U >
bool operator!= ( const rc_ptr< T > &  lhs,
const U *  rhs 
)
friend

True if and only if the target of lhs is not rhs.

Definition at line 100 of file rc_ptr.h.

◆ operator!= [4/4]

template<typename T>
template<typename U >
bool operator!= ( const U *  lhs,
const rc_ptr< T > &  rhs 
)
friend

True if and only if lhs is not the target of rhs.

Definition at line 109 of file rc_ptr.h.

◆ operator== [1/4]

template<typename T>
bool operator== ( const rc_ptr< T > &  lhs,
const T *  rhs 
)
friend

True if and only if the target of lhs is rhs.

Definition at line 49 of file rc_ptr.h.

Referenced by sheaf::rc_ptr< T >::operator!().

◆ operator== [2/4]

template<typename T>
bool operator== ( const T *  lhs,
const rc_ptr< T > &  rhs 
)
friend

True if and only if lhs is the target of rhs.

Definition at line 57 of file rc_ptr.h.

◆ operator== [3/4]

template<typename T>
template<typename U >
bool operator== ( const rc_ptr< T > &  lhs,
const U *  rhs 
)
friend

True if and only if the target of lhs is rhs.

Definition at line 82 of file rc_ptr.h.

◆ operator== [4/4]

template<typename T>
template<typename U >
bool operator== ( const U *  lhs,
const rc_ptr< T > &  rhs 
)
friend

True if and only if lhs is the target of rhs.

Definition at line 91 of file rc_ptr.h.

◆ same_target

template<typename T>
bool same_target ( const rc_ptr< T > &  xp1,
const rc_ptr< T > &  xp2 
)
friend

True if xp1 and xp2 point to the same target.

Definition at line 119 of file rc_ptr.h.

◆ target_ref_ct

template<typename T>
size_type target_ref_ct ( const rc_ptr< T > &  xp)
friend

The reference count of the target of xp.

Definition at line 127 of file rc_ptr.h.


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