cgv
cgv::data::ref_ptr< T, is_ref_counted > Class Template Reference

#include <ref_ptr.h>

Public Types

typedef ref_ptr< T, is_ref_counted > this_type
 type of the reference counted pointer
 
typedef ref_ptr_impl< T, is_ref_counted > base_type
 type of base class that implements the reference count specific methods
 

Public Member Functions

 ref_ptr (T *p=0)
 construction from pointer or empty if pointer is not given
 
 ref_ptr (const this_type &r)
 copy constructor for reference pointers of the same type
 
 ~ref_ptr ()
 destruct reference counted pointer
 
template<typename S >
 ref_ptr (const ref_ptr< S, is_ref_counted > &s)
 allow to copy ref_ptr to a ref_ptr<T> if T is a base class of S and if T has a virtual destructor
 
template<typename S >
ref_ptr< S, is_ref_counted > up_cast () const
 use static cast to convert from T to S if T is a base class of S and has a virtual destructor
 
this_typeoperator= (const this_type &r)
 assignment to pointer of same type
 
template<typename S >
this_typeoperator= (const ref_ptr< S, is_ref_counted > &r)
 assignment to pointer of derived type with virtual destructor
 
T & operator* () const
 access to element
 
T * operator-> () const
 access to element pointer
 
bool operator== (const this_type &r) const
 compare by pointer
 
bool operator< (const this_type &r) const
 compare by pointer
 
bool operator!= (const this_type &r) const
 compare by pointer
 
bool unique () const
 check if this is the only reference
 
bool empty () const
 check if pointer is not yet set
 
 operator bool () const
 conversion to bool results in false if the stored pointer is a null pointer
 
void clear ()
 set to null pointer
 

Detailed Description

template<class T, bool is_ref_counted = type::cond::is_base_of<ref_counted,T>::value>
class cgv::data::ref_ptr< T, is_ref_counted >

reference counted pointer, which can work together with types that are derived from ref_counted, in which case the reference count of ref_counted is used. Otherwise a reference count is allocated and access to the stored instance needs to follow two pointers.


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